1

I've got a D7 installation for some time now, with a content type that has a "private file" field.

It was working just fine up until now.

My files usually got uploaded like: http://....com/system/files/curso/file.txt And they get saved inside: .../files/private/Private - accessible only to group members/[nodeid]/file.txt

Now I've created a new node with an uploaded private file: demo.txt

When its downloaded it gets this path: http://....com/system/files/curso/demo_1.txt

But I get "Not Found" when I click it because it gets saved in other location (?): .../files/private/curso/demo_1.txt

Notes

  • The _0, _1 etc are automatically added to the files when they are saved into the node.

  • I've tried accessing the file from its real location (.../files/private/curso/demo_1.txt) with no luck.

  • The "files" folder is directely inside public_html because the original setting was that way (the site comes from a D4.7, D5 and then a D6 installation).

  • It worked just fine with other files up until now. I've not done anything special (like installing new modules), except creating a few new node types and rebuilding the permissions.

What could I do? (BTW, I've read this information, and sadly it didn't helped).

Update - Error Logs:

[Mon Mar 02 12:37:40 2015] [error] [client 181.28.74.188] client denied by server configuration: /home/sitio/public_html/files/private/curso/demo_1.txt (I've found more info about this here)

5
  • Can you actually see the uploaded file in your file system ? (did it upload ok regardless of the incorrect path ?)
    – rtome
    Mar 2, 2015 at 16:05
  • Also, have you got anything unusual in the watchdog (recent log messages queue) ? Also can you check in the apache/php error log ?
    – rtome
    Mar 2, 2015 at 16:07
  • @rtome, yes, the file is indeed uploaded. I haven't seen anythin unusual at the logs, looking into the apache ones now...
    – Rosamunda
    Mar 2, 2015 at 16:08
  • @rtome, I've updated the question, yes, there's this error only at the apache logs: [Mon Mar 02 12:37:40 2015] [error] [client 181.28.74.188] client denied by server configuration: /home/sitio/public_html/files/private/curso/demo_1.txt Hm, I just realized that there's no .htaccess file inside that private folder... could that be related to the "client denied by server configuration" error?
    – Rosamunda
    Mar 2, 2015 at 16:19
  • yes, its related. Either setup and .htaccess file for your /home/sitio/public_html/files/private/curso/ directory or edit your apache conf file for your site and add the relevant Directory block.
    – rtome
    Mar 2, 2015 at 16:29

1 Answer 1

1

You spoted your problem in your apache log file : Apache is forbiding access.

You have 2 options here :

If you want apache to allow access to these files then add this to apache conf file :

<Directory /home/sitio/public_html/files/private/curso>
  AllowOverride None
  Order Allow,Deny
  Allow From All 
</Directory>

then restart apache and I guess you should be ok to access your file.

But if you want these files to be private then you want to restrict access rather than open it, so

Alternatively,

you let apache restrict access to these files, and you set drupal serve these files via alternative drupal-generated links. Check the documentation for setting up access to private files here, look for the section on "Accessing Private Files".

If you've got no .htaccess file for the folder as you said then create one with :

Deny from all
Options None
Options +FollowSymLinks
11
  • Thanks for your reply! The only question that remains is that... shouldn't that folder be protected? I mean Allow From All seems a wide permission for a private folder.
    – Rosamunda
    Mar 2, 2015 at 20:57
  • Depends who you want to restrict access to the folder. See the apache documentation for your config choices : httpd.apache.org/docs/current/en/mod/mod_access_compat.html . You could set ip filtering or something like that.
    – rtome
    Mar 2, 2015 at 22:08
  • I've dug this a bit further and I'd advice you to have a look at the drupal documentation on accessing private files. I've updated my answer on this regard.
    – rtome
    Mar 2, 2015 at 22:24
  • Thanks for your kind reply! I'm still struggling with this, because after checking the .htaccess file (filled with "Deny from all...") is inside "private" folder, all new files get the 404 error. Older files inside the same folder get accessed just fine. I'm accessing all of them as admin. I've read the Drupal docs, and checked that everything was as they said. Anyway, don't understand why I cannot access new files while I do access older the ones already uploaded.
    – Rosamunda
    Mar 3, 2015 at 22:51
  • ok, you've set your private destination for file upload ? And your file field has still private files as upload destination ?
    – rtome
    Mar 4, 2015 at 9:10

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.