Problem with file permission, when I upload a file cannot upload the file? unless I do 777 file permission for folder upload, each time I do

I am using virtual host. I created a website. I am uploading images to the specific folder. Te problem I am facing is: 1: Cannot upload. 2: The solution I am doing now, I enter using file zilla. I select the folder then I make the permission 777. I can upload for 5 or 6 photos then It back. I really need help. I need to make it 777 for live. The problem I heard that 777 is problem for a website. Please give me an advice. Thanks

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


Using a chmod of 777 grants world read, write, and execute, so it’s not exactly secure and I would not recommend keeping those permissions.

With properly setup user and group permissions, you shouldn’t need such open access – generally all files are at least 644 and directories 755. Since you’re using Apache, the files and directories need to be owned by the user that Apache is running as.

In most cases, www-data is the user and group that Apache uses, unless you’ve configured it to use another user or the repository you’re using has done so.

So what you need to check is ownership. You can see what user and group owns a file or directory by using ls -al on a directory.

You’ll see something like:

drwx------  5 root root 4096 Apr 19 21:20 .
drwxr-xr-x 23 root root 4096 Apr 19 02:05 ..

If you’re seeing root on the third and fourth column in the directory where your files are located, then that’s probably the issue.

You can change ownership permissions using chown which also supports recursion, like chmod.

For example, to change ownership of files in /var/www/html to www-data, we’d use:

chown -R www-data:www-data /var/www/html

thank you so much I will try it now.

SSH to the machine then cd to the directory and run the following.

sudo chmod -R 777 /path/to/dir