简体   繁体   中英

“Unable to access” with move_uploaded_file() PHP

The function move_uploaded_file() isn't working on my server and I really dont know why. the error:

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to access MYADDRESS/img-19.png in MYADDRESS/index.php on line 660

I gave to the folder which I upload files chmod 777. any solution? im sure 100% the problem isn't in my code.

Make sure you have it in the $src, $dest order:

move_uploaded_file($_FILES["field"]["tmp_name"], 'foo.png');

Also, check PHP settings, especially safe_mode and base dir restrictions.

Side note: Don't chmod your folders to be world writable! Change the group of the folder to be that of the webserver, and use 775. Last thing you need is something like an SQL injection from MySQL writing a PHP file into that folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM