简体   繁体   中英

upload image to aws ec2 with php

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?

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM