PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Warning: move_uploaded_file(/images/animal_party_elephant_mask.gif): failed to open stream: No such file or directory in /home/ace/public_html/ace_cart/admin/check_product.php on line 20
The destination you give it is a file system reference, not document root reference, so /images would be the images directory in the root of the server, likely not where you want it. you may want to use $_SERVER['DOCUMENT_ROOT'] to help you specify the correct directory.
Warning: move_uploaded_file(images/animal_party_elephant_mask.gif): failed to open stream: Permission denied in /home/ace/public_html/ace_cart/admin/check_product.php on line 20
Warning: move_uploaded_file(): Unable to move '/tmp/php0B6PYh' to 'images/animal_party_elephant_mask.gif' in /home/ace/public_html/ace_cart/admin/check_product.php on line 20
For that, you will need to set the permissions of the images directory so that php can write to it. The setting you need can easily vary from server to server due to different ways of setting them up. The easiest, and most insecure is 0777. I would not recommend using that, but it will get it working. The problem would be other users on the server or allowing a "bad" file to be uploaded. But we've gone over the security concerns about that before.
How would i set the permission of the image directory?
Would this be done through php or in the server cpanel?
I've changed the directory path so that the image is moved to the correct place but now i get this message:
Warning: move_uploaded_file(/home/ace/public_html/ace_cart/admin/images/animal_party_elephant_mask.gif): failed to open stream: Permission denied in /home/ace/public_html/ace_cart/admin/check_product.php on line 23
Warning: move_uploaded_file(): Unable to move '/tmp/phpLk9EgI' to '/home/ace/public_html/ace_cart/admin/images/animal_party_elephant_mask.gif' in /home/ace/public_html/ace_cart/admin/check_product.php on line 23
It does indeed sound like a permission issue. I just don't know how to set or alter the permission.
move_uploaded_file() is the only "copy" you should ever use with uploads. Try using copy() or rename() with safe_mode on, you'll find out why.
As for chmodding the folder, you could use your favorite FTP often. If not, cpanel can generally do it too. Again, I'd suggest to avoid 777 as it's very insecure. Read the previously linked thread for details on how to decide the best permission level.
Worst case, you can run the permutations of permissions. There are 511.