Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Can someone help me understand why this is returning false?

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

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

Cheers!

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) } }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
302 views
Welcome To Ask or Share your Answers For Others

1 Answer

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);

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...