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?