How do I change chmod settings to allow for file upload?

4.4k views Asked by At

I've been trying to get get my PHP script to upload files. However, I come across this error:

  Warning: move_uploaded_file(images/faceBackground.png) [function.move-uploaded-file]: failed to open stream: Permission denied in /f5/mvcsf/public/portfolios/members_profile_chg.php on line 31

  Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/f5/mvcsf/tmp/phpjY9EBB' to 'images/faceBackground.png' in /f5/mvcsf/public/portfolios/members_profile_chg.php on line 31

After scouring multiple solutions on Stackoverflow, I got the hint that I should change the chmod settings. So I went into Filezilla and tried to change the file permissions for members_profile_chg.php(which contains the upload script) to 0755 and then to 0644, but neither worked. Any ideas? I'm using nearlyfreespeech as my web server if that makes any difference.

3

There are 3 answers

2
Jigar On BEST ANSWER

chmod 0777 the images folder instead of files.

0
Bart Friederichs On

Make sure your images directory is accessible and writeable (rwx) for the server user (probably apache).

~$ chmod g+rwx,o+rwx images/

Note that this makes the directory world-writable. Better is to only give the server user access (assuming it is apache):

~$ chown apache images/
~$ chmod g+rwx,o+rx images/

More information can be found here.

The numerical values you want to try are 0775 or 0777.

0
Nithin S On

give permission to target folder folder in which permission 0755 or 0777 will work .also make sure that there is a folder named 'images' in the 'portfolios'

if the images is on the root try

move_uploaded_file("/images/faceBackground.png")