为什么图片上传失败 php 的 is_uploaded_file 检查? [英] Why does image upload fail php's is_uploaded_file check?

查看:15
本文介绍了为什么图片上传失败 php 的 is_uploaded_file 检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个允许上传图片的 html 表单,但现在上传的图片由于某种原因未能通过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 检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆