ÎÒÓÐÒ»¸öÔÊÐíÉÏ´«Í¼Æ¬µÄ html ±íµ¥£¬µ«ÏÖÔÚÉÏ´«µÄͼƬÓÉÓÚijÖÖÔÒòδÄÜͨ¹ýis_uploaded_file"¼ì²é.
I have a html form that allows image uploads, but the image uploaded now fails the "is_uploaded_file" check for some reason.
ÄÇôΪʲôÉÏ´«Ê§°ÜÁË is_uploaded_file ¼ì²é?
HTML:
<form enctype="multipart/form-data" id="RecipeAddForm" method="post"
action="/recipes/add" accept-charset="utf-8">
<!--- Omitted Markup -->
<input type="file" name="data[Recipe][image]" value="" id="RecipeImage" />
<!--- Omitted Markup -->
</form>
PHP:
// returns false
echo is_uploaded_file($file['tmp_name'])?'true':'false';
ÎÒ¶Ô $file »ò $_FILES Êý×é½øÐÐÁËת´¢:
I did a dump on the $file or $_FILES array:
Array
(
[name] => add or remove.jpg
[type] => image/jpeg
[tmp_name] => E:\xampp\tmp\phpB9CB.tmp
[error] => 0
[size] => 71869
)
Îļþ´óС²»ÊÇÌ«´ó£¬´íÎóΪ0£¬ÎªÊ²Ã´is_uploaded_file¼ì²éʧ°Ü?
File size is not too large, and the error was 0. So why does it fail the is_uploaded_file check?
¿ÉÄÜÊÇwindowsµÄÎÊÌ⣬ÒòΪËüÇø·Ö´óСд£¬Èç¹û·¾¶²»Í¬Ôò²»Æ¥Åä.³¢ÊÔʹÓà realpath($file['tmp_name'])
Might be a problem with windows, since it's case sensitive and will not match if the path is different. Try using realpath($file['tmp_name'])
Õâƪ¹ØÓÚΪʲôͼƬÉÏ´«Ê§°Ü php µÄ is_uploaded_file ¼ì²é?µÄÎÄÕ¾ͽéÉܵ½ÕâÁË£¬Ï£ÍûÎÒÃÇÍƼöµÄ´ð°¸¶Ô´ó¼ÒÓÐËù°ïÖú£¬Ò²Ï£Íû´ó¼Ò¶à¶àÖ§³Ö¸ú°æÍø£¡