0

I have an application where people can upload files to my s3 bucket. But before the file is uploaded, it needs to be temp installed onto the computer. So now that I'm hosting the application on my aws ec2 instance, a temp file needs to be installed on to the ec2 instance/var/www/html/cactusjan25/videouploads/ before it goes to my s3 bucket everytime someone wants to upload a file. However, for some reason files cannot be uploaded to the ec2 instance. Are there any permission I need to set to allow any random person from anywhere in the world to upload a file to that temp directory on my ec2 instance?

  • @thilinajayanath hopefully I'm not confused or anything but can I use filezilla for the FTP server you mentioned? –  Feb 01 '20 at 17:30
  • Sorry! I removed my comment as I wanted to know more information. Is your application going to upload files to the ec2? – Thilina Jayanath Feb 01 '20 at 17:30
  • @thilinajayanath Well the files will need to be uploaded to the ec2. I'm using php for this. The file gets insatlled when I'm just using a localhost to run my application. However when I'm using the ec2 instance, the files are not uploaded. –  Feb 01 '20 at 17:40
  • Does the application run in the ec2 itself? Or does it run in users' computer? – Thilina Jayanath Feb 01 '20 at 17:43
  • I'm not exactly sure how to answer this. It works by users going to link (on the internet) for the ec2 instance and then they use the website that I have uploaded onto it the ec2 instance. –  Feb 01 '20 at 17:45
  • In this case, you don't need any additional application as the php application is in the ec2 itself. You should be able to save the files in the ec2 that are uploaded by users of the application. Check if the service user that is running the web server has permission to the directory you want to write files to. – Thilina Jayanath Feb 01 '20 at 17:52
  • How do I check that? –  Feb 01 '20 at 17:56
  • I'm using apache to run my php code. When you say service user, are you refering to that? (Apache) –  Feb 01 '20 at 18:11
  • Depends on the OS in the ec2 instance. In Linux you can try `ps aux | grep apache | grep -v grep`. I don't know how to do it in Windows. – Thilina Jayanath Feb 01 '20 at 19:32
  • I got this error: `move_uploaded_file(videouploads/5e35f76b8d2090.27429466.mp4): failed to open stream: Permission denied in /var/www/html/cactusjan29/uploadfile.php on line 142.` I reuploaded my website and made it show all the errors. I also am using linux. I tried to command you showed but I don't know what to do after. –  Feb 01 '20 at 22:16
  • Take a look at this - https://stackoverflow.com/questions/8103860/move-uploaded-file-gives-failed-to-open-stream-permission-denied-error The issue you are having is not related to ec2 rather permissions in linux. Basically apache cannot write to the destination folder. Above question has an anwer explaining how to fix it. – Thilina Jayanath Feb 01 '20 at 23:07
  • Yes I already took a loot at that. However it refers to httpd and my ec2 instance has nothing related to that. My instance also doesnt recognize the command`$ps aux | grep httpd`. And when I change the permission like it shows, I still get the same error, permission denied. –  Feb 01 '20 at 23:33
  • Can you post the output of these commands in your question? `ps -ef | egrep '(httpd|apache2|apache)' | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}'` `ls -al /var/www/html/cactusjan29` – Thilina Jayanath Feb 02 '20 at 09:19
  • I found another solution. I gave apache permission to write stuff into the folders I selected. –  Feb 02 '20 at 16:16
  • `sudo chown -R www-data:www-data /var/www` `sudo chmod -R g+rwX /var/www` –  Feb 02 '20 at 16:35

0 Answers0