grasig grasig - 7 months ago 71
PHP Question

How to check if move_uploaded_file function has error

i have the following code for uploading the file on my folder and it is working on localhost, but when i uploaded the code online, it's not working though i have put the correct path. Is there any way i could see the reason or error why?

move_uploaded_file($img_tmp,"../images/profile/$post_image1");

Answer

What about directory permissions for your destination? Have you cross-checked that?

try chmod -R 777 /var/www/your_project_name

This might help :)

Also, check what's your function move_uploaded_file is returning?

"Returns TRUE on success.

If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.

If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued."