1

I've set up a private directory sites/default/files/private and use it for a file field.

As an admin, everything works as expected when uploading and viewing a private file.

As a user who uploads a private file, I can only download own private files with the Views formatter Download link (example.com/file/585/download?token=TcBjzT2I), but not view them via Generic file (example.com/system/files/private/mypic.jpg) or other formatters. When using the latter, I get

"Access Denied You are not authorized to access this page."

Permission "View own private files" for role enabled. Even enabling "View private files" has no effect.

What am I missing?

0

Files in the private directory are not accessible directly through the web server;

You may have to use file_create_url or hook_file_download to access the files under private directory.

For More info on Accessing Private Files check here

  • Thanks, Kstack. What I don't understand is why can the admin view the files then? – xinxin Oct 23 '17 at 10:57

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.