-2
  1. When we upload an image using the URL 'https://website.com/file/add' , the image is getting uploaded. While uploading, we have chosen the destination as ' Public local files served by the webserver' and the media folder as 'Media Root'.
  2. But when we hover over the uploaded image inside https://website.com/admin/content/file, its showing "The file doesn't exist".
  3. And when we try to access the uploaded image, then either of the following messages would show up:-
    1. Warning: filesize(): stat failed for public://download (2).jpg in file_save()(line 614 of /var/www/html/website/includes/file.inc).
    2. Page not Found Error - The requested The requested URL "/sites/default/files/image.jpg" was not found on this server.

My website is working under Drupal 7(7.63) and hosted in AWS. There are 2 servers under a load balancer. PHP:- Version 5.5.9-1ubuntu4.17. The public directory mentioned in the file system is 'sites/default/files' and it has given 777 permission.

Could anyone please guide me on how to solve this issue? Is this issue related to server-specific configurations?

Thanks

  • 1
    My website is working under Drupal 7(7.63) There was a security update in 7.65. You should update to the latest, as of this writing, 7.66 – No Sssweat Apr 26 at 10:54
0

Configuration examples

For example, on many systems the Apache process runs as a user called "www-data" that is in a group called "www-data". This user should be able to read all of the files in your Drupal directory either by group permissions or by "other" permissions. It should not have write permissions to the code in your Drupal directory. If you use features of Drupal which require the "files" directory, then give the www-data user the permission to write files only in that directory.

The following is an example file listing of a safe configuration showing two files in a site where uploaded files are stored in the "files" directory. In order to see the file permissions set for your setup, go to the command line and type: ls -al.

drwxrwx---  7 www-data    greg-group  4096 2008-01-18 11:02 files/
drwxr-x--- 32 greg-user   www-data    4096 2008-01-18 11:48 modules/
-rw-r-----  1 greg-user   www-data     873 2007-11-13 15:35 index.php

source: Securing file permissions and ownership

Your issue is that the /files folder has the wrong owner. (The 1st one is the owner, the 2nd is the group).

In SSH command line, you need to do:

cd /var/www/html/website/sites/default

For checking purposes do

ls -al

You will see that your files folder has the wrong owner. (The 1st one is the owner, the 2nd is the group).

To fix it, now do:

sudo chown www-data:<the-group-name> -R files

Note: Replace <the-group-name> with your actual group name, without the <> part. I'm just indicating it's a place holder.

DO NOT DO:

NOTE: THIS IS AN INSECURE CONFIGURATION
drwxrwx---  7 www-data  www-data  4096 2008-01-18 11:02 files/
drwxrwx--- 32 greg-user www-data  4096 2008-05-16 11:48 modules/
-rw-rw-rw-  1 www-data  www-data   873 2007-11-13 15:35 index.php

source: Securing file permissions and ownership

Related:

  • Thank you No Sssweat for providing me with the solution in detail. Currently the owner:group is www-data:www-data for '/files' folder. Could you please help me on how to get the real group name of the owner 'www-data'? – N N Apr 26 at 12:09
  • www-data user's group name is www-data. What you want is to use the group name of your commanline user. If you're on ubuntu use ubuntu. If it's root use root. If you type the command groups that will list you all the groups. – No Sssweat Apr 26 at 12:29
  • Basically use the usernane you used to login to SSH, as tipically their group name is the same name. So www-data:<ssh-user-group> – No Sssweat Apr 26 at 12:36
  • ok I have tried changing the group of www-data for 'files' folder. But still the issue persists. What shall be the solution now? Is the issue related to :- 1.Missing of policy to the user/group you are using under "Identity & Access Management." 2. Missing of certificate. 3. .htaccess problems: Options +FollowSymLinks present in the current htaccess. – N N Apr 26 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.