php file upload capitalized filename issue

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 04:30:15

问题


I have a pretty standard file upload form (that is also writing to a mysql db). It was working fine throughout my testing, then I went and tested a file that was named with all capital letters. The file would not upload. Simple solution I figured, just rename the file before the upload with 'strtolower' but no luck. Also tried strtoupper, still no luck. I think I'm also running into this issue with files starting with numbers. (i did double check and yes the folder is writable.)

$upload_dir = "/path/to/the/upload/folder/entries/";
$new_filename = mysql_insert_id()."_".$filename;
$tmp_name = $_FILES["filename"]["tmp_name"];
move_uploaded_file($tmp_name, $upload_dir . $new_filename);

any help is GREATLY appreciated.


回答1:


Need to isolate the step where the error is happening--what do you mean specifically, "the file will not upload"? Does no file get to the server? Does the rename not work? Is the mysql statement doing the insert not formed correctly? If the file never gets to the server, then you have nothing on which to invoke strtolower.

Take a known, working, uploadable file, upload it to be sure it works, then rename it to its uppercase version and try again. If picture.jpg works, does PICTURE.JPG? Or PICTURE.jpg? I'm wondering if there's something in the previous parts of your code that is deciding ".JPG" (or whatever capitalized extension) isn't a valid upload like ".jpg" is.



来源:https://stackoverflow.com/questions/1987775/php-file-upload-capitalized-filename-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!