PHP: move_upload_file() saves file with wrong extension
Server:
CentOS release 5.3 (Final) x86_64
PHP 5.3.2
Apache 2.2.3
PHP Code:
error_log('Move from: ' . $开发者_如何学编程_FILES[$upload_name]["tmp_name"]);
error_log('Move to: ' . $save_path.$file_name);
if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path.$file_name)) {
HandleError("File could not be saved.");
exit(0);
}
PHP error_log:
[error] [client XXX.XXX.XXX.XXX] Move from: /tmp/phpX9pxKt
[error] [client XXX.XXX.XXX.XXX] Move to: /path/to/files/temp/1301512183822bb.avi
Actual file saved on file system:
1301512183822bb.XXX
Where XXX is three random letters/numbers, I have seen .cb2, .ozz, .abc, .oar, .jhz, list is never ending...
Summary: move_uploaded_files saves the file with a random extension. Files contents are fine, the only problem is the file extension.
No updates were applied. Nothing on the server changed. This randomly started occuring. Server has been running for months fine until now. I've tried restarting apache, even tried a server reboot.
Nevermind, it's bad code after what I pasted above. The code for this software is poorly written. I would suggest staying far from this software, even if it is free.
精彩评论