move_uploaded_file失败 [英] move_uploaded_file failure

查看:132
本文介绍了move_uploaded_file失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我理解为什么这会返回false吗?

Can someone help me understand why this is returning false?

if ((move_uploaded_file($_FILES[$field]['tmp_name'], $path))) {

如同潜在原因一样。我已检查变量是否正确,并且我已检查目标文件夹的权限是777。

As in, potential causes. I have checked the variables are correct and I have checked permissions on the destination folder which is 777.

干杯!

对于那些想看var_dump($ _FILES);

For those wanting to see var_dump ($_FILES);

array(1) { ["image"]=>  array(5) { ["name"]=>  string(14) "accountile.png" 
["type"]=>  string(9) "image/png" ["tmp_name"]=>  string(14) "/tmp/php28IQhv" 
["error"]=>  int(0) ["size"]=>  int(394) } }


推荐答案


我检查了变量

I have checked the variables

不检查变量,但检查错误消息。

这是你唯一需要的东西。

在你的代码顶部添加这些行

Do not check variables but check error messages.
It's the only thing you need.
Add these lines at the top of your code

ini_set('display_errors',1);
error_reporting(E_ALL);

并查看它的内容。

如果move_uploaded_file失败,它将总是使用详细解释引发错误。

您不会相信它,但阅读错误消息是比

and see what it says.
If move_uploaded_file failed, it will always raise an error with detailed explanation.
You won't believe it, but reading error messages is way more efficient way to find a problem than guesswork you tried before

我不敢相信没人提到它。

I can't believe noone mentioned it already.

这篇关于move_uploaded_file失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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