简体   繁体   English

使用php将图像上传到AWS EC2

[英]upload image to aws ec2 with php

I'm trying to upload a file to a virtual machine in Amazon. 我正在尝试将文件上传到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. 我认为我必须授予(777)服务器文件夹权限才能上传文件。 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. 您无需将文件的权限设置为777,就可以将其写入目录。 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. 如果您正在运行apache,则该进程将以用户www-data身份运行,并且无论您要将文件写入哪个位置,都必须具有该用户的写许可权。 If you are writing to /var/www/my_file_uploads , then try this: 如果您正在写入/var/www/my_file_uploads ,请尝试以下操作:

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). 请注意,通过这样做,您将防止家用计算机上的其他人也读取该文件(除非您明确允许)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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