简体   繁体   中英

Cant' Upload files to AWS through PHP file upload

I guess this is just a permissions problem on AWS but I'm not very proficient at linux commands.

I've moved a site from another server to AWS and after a while, everything run perfect except for the PHP file uploads.

I have an User area where users can upload pictures to their profiles and perform some activities, that was working fine in the previous server.

But in AWS it doesn't save the uploaded file. My code return success on every validation I added to the file upload but the file doesn't get saved at the server.

I'm pretty sure it's a permissions issue, I've tried with the command chown ec2-user /var/www/html and also tried granting permission to root, but none of those have worked.

FTP works fine, just the uploads from the user's area are the ones that don't work.

could any of you help me to find a solution?

Thanks!

When using PHP to upload a file on the server, you have to grant the webserver write permission.

If you are using apache for example, you can run the following command :

chown apache:apache /var/www/html
chmod 775 /var/www/html

Also, the whole tree structure must be at least readable. You should have something like this :

drwxr-xr-x root:root /var
drwxr-xr-x root:root www
drwxr-xr-x apache:apache html

In Aws there are many things that you have to take in account.

1) Did you Install and Enable Some FTP Program , Make user accordingly and Gave Directory Access to that user.

(Because By Default you will only have SFTP Access to instance)

2) Did you Allow the PORT 21(ftp) in Security Group.

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