1

I'm trying to upload a file to a virtual machine in Amazon. and i have some questions.

I think i have to give (777) permissions to my server folder to be able to upload my file. if i don't it won't work. is this ok?

is it secure to give those permissions?

4
  • 1
    777 is never secure! Why do you need to give those permissions? whathaveyoutried.com ? Commented Feb 12, 2013 at 1:41
  • what permissions should i give? 755 right? i need to upload images to my server Commented Feb 12, 2013 at 1:44
  • What are you using to upload these images? The answer will depend on that Commented Feb 12, 2013 at 1:45
  • im using a php function "move_uploaded_file" Commented Feb 12, 2013 at 2:02

1 Answer 1

6

You don't need to make the file's permissions 777 in order to be able to write it into a directory. Instead, the directory needs to have permission to be written to by the user.

If you are running apache, the process runs as the user www-data and wherever you are trying to write the file to, must have write permissions by this user. If you are writing to /var/www/my_file_uploads, then try this:

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

Note that by doing this, you will be preventing others on your home machine from reading the file as well (unless you explicitly permit it).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.