How to set correct permissions for an upload folder with PHP

Keywords: LAMP/MAMP/WAMP - AWS - Technical issue - Permissions
What is the correct way of setting permissions on a upload folder?

I need PHP be able to move_uploaded_file (even if it is a new file or replacing a file that was previously upload by FTP) and I also need to upload a new file from FTP (and should work if it is a new file or replacing a file created by PHP)

Hello @prada-v,

That folder should have write permission for daemon user. I would suggest changing the permissions to the folders where your application requires write privileges. You can use bitnami:daemon and 775 for directories and 664 for the files.


Hello @davidg

I’ve set the folder as 775 and Owner/Group as bitnami/daemon. Files inside this folder, when uploaded through webpage (PHP move_uploaded_file function) are set as 664 and Owner/Group as daemon/daemon.

If I need to replace the file through FTP I get the error “open for write: permission denied”. I can delete the file (I don’t understand why) and upload a new file, but I want it to work as file replace. How can I achieve that?


Hi @prada-v,

You could access via SSH an alter it as root user.

As an alternative to using the command line, you can modify the bitnami user so it belongs to the daemon group. With that, the bitnami user should be able to modify these files. To do so, please connect to your server via SHH and run the command below:

sudo usermod -a -G daemon bitnami