Hi all,
I wrote a php script that will upload an image to a folder set to 0777.
However, from my understanding this is not the safest way to upload a file. I was suggested to change the folder back (chmod) to 0755, and use the chmod in my php script before that will set the folder to 0777 while the image is uploaded; and back to 0755 after the process is complete.
I tried writing the script to do this but i received the following error:
chmod(): Operation not permitted in (my file)
Could somebody please review my chmod code and provide a solution?
Code:
chmod("…/image_bin/", 0777);
move_uploaded_file($_FILES[‘file’][‘tmp_name’],’…/image_bin/’.$_FILES[‘file’][‘name’]);
chmod("…/image_bin", 0755);
Thank you!