I have a site (Linux/Drupal/Apache) that generate a .xlsx file from custom code and its saved to files, but after that I cannot download it from drupal, it give permission denied.

You don't have permission to access xxxxxxx.xlsx on this server.

The upload file is saved with -rw------- or 600 permission, and the user/group from Apache.

If I chmod the file to 644 it works.

How can I made that any file generated in that way, will be -rw-r--r-- or 644 ?

  • What upload method are you using?
    – Darvanen
    Mar 16, 2015 at 22:21
  • File not uploaded, its generated from code. Question edited.
    – atlus
    Mar 16, 2015 at 22:45
  • Ok, so provide the code you're using to generate and save the file.
    – Darvanen
    Mar 16, 2015 at 23:50
  • I think you should modify the permissions of the folder containing the files. The files should inherit access rights from the parent folder.
    – BorisR
    Mar 17, 2015 at 1:13
  • container folder have 755 permissions, but the newly created file its not inheriting permissions, as its being created as 600.
    – atlus
    Mar 17, 2015 at 1:28

2 Answers 2


A few things to check:

  1. make sure there is no .htaccess rule that is preventing the download (it may be inherited).
  2. If using file entity check: /admin/config/media/file-settings and make sure .xls is allowed.
  3. Could be blocked by server security like modsecurity rules, check the apache logs...

Execute a drush status-report and see if you have any problems that Drupal detected.

If not comfortable with drush, navigate to [yoursitename]/admin/reports/status and see if you have any action items (highlighted in red)

How can I made that any file generated in that way, will be -rw-r--r-- or 644 ?

You can check your default perms by executing umask (http://en.wikipedia.org/wiki/Umask). It is usually 0022. If it is something like 0077, then you will have to change it, if it isnt then dont worry about it right now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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