I installed the newest stable module (6.x-1.0-rc2) and am trying to upload files but anything I put up is completely inaccessible. When I click 'private' next to the file upload the file goes into the \sites\default\files\private folder but if I go to 'private/filename' I get the message:

"You don't have permission to access /sites/default/files/private/filename on this server"

The .htaccess in the private folder sayas "Deny from all" is this correct? I'm also using the Node Privacy by Role module if that's relevant. Any help would be great.

Comments

starbow’s picture

Status: Active » Postponed (maintainer needs more info)

Interesting.
Any chance you could test with node privacy by role turned off?

bmeier’s picture

I disabled 'Node privacy by Role' and am getting the same result. If I edit a page and change the file to public I am able to access it.
The .htaccess file in my \default\files folder looks like this:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

and in the private folder:

SetHandler This_is_a_Drupal_security_line_do_not_remove
Deny from all

I am running Apache 2.2 - could it possibly be an error with my servers access settings?

starbow’s picture

Assigned: Unassigned » starbow
starbow’s picture

Status: Postponed (maintainer needs more info) » Active

I took another look at your bug report, and on second look it seems like you are describing the expected behavior. Files in the private directory cannot be directly access, since that won't give Drupal a chance to control access to them. private/filename must be accessed by the path system/private/filename.

tirdadc’s picture

Title: Cannot Acces any Private Files » Cannot Access any Private Files
Priority: Normal » Critical

I can't access any of the files ("Access Denied" page) even when using the right path (ie system/files/private/test.doc) unless I'm logged in as the superadmin.

I can view the nodes to which the files are attached fine though, and I'm not using any node privacy module. The "view uploaded files" permission is set for the other roles I tried this out with. Any suggestions? Where is the check performed in the code when accessing system/files/private/test.doc to forward to the actual file?

tirdadc’s picture

Priority: Critical » Normal

Never mind, I ended up achieving what I needed without this module and by using hook_file_download(), which works on D5 even with a public download method for the site. This (in tandem with an .htaccess file) allowed me to restrict access to a CCK filefield's file just fine.

starbow’s picture

Status: Active » Closed (fixed)
garyg’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

Sorry you didn't get this problem resolved using private_upload.
I have the same issue and would love to get it working properly.
I can view the private files when logged as admin but only admin.

burningdog’s picture

Component: Miscellaneous » Code
Priority: Normal » Critical
Status: Postponed (maintainer needs more info) » Closed (fixed)

I had the exact same issue as garyg. Downloaded and installed the 6.x-1.0-rc2 version of Private Upload. Enabled it and set it up correctly (everything was "great"!). If I add a node and attach a file normally, I can view that file. If I check the "Private" checkbox next to it, I cannot access the file, even with user 1.

The issue was this: I'm developing another module which implements the file_download() hook. The module was incomplete and was returning a value to Private Upload telling it to tell the user "Access Denied." This made it seem like the Private Upload module was broken - but it's working fine!

My suggestion, if you're having issues getting it to work, is to disable all contrib modules (especially any which deal with files) and then re-enable them one-by-one. Or, search through the contrib modules folder (sites/all/module) for any function which is an implementation of hook_download - the function's name will end with "file_download" - then disable that particular module to see if that fixes it.

bmeier’s picture

Priority: Critical » Minor

I took your suggestion burningdog and found that download_count was interfering with private upload, disabling that fixed the "Deny from everybody" problem I was having and private uploads work great now.

bmeier’s picture

edit: double post

rpandey1’s picture

Thanks a lot on the suggestions that of contributed modules test. I was really going crazy with the issue because everything was great as suggested but still could not view the files if set to private till I came across this thread.

The culprit in my case was 'private download'. Once I disabled it private upload worked perfectly.

Thanks
rpandey

Magual’s picture

Priority: Minor » Normal
Status: Closed (fixed) » Active

I am also seeing the same problem. I searched in the modules directory (/sites/all/modules) and found that only private_upload and a module called fckeditor had a "file_download" reference. I disabled fckeditor and still see the issue.

I remember testing the system a while ago and it used to be working properly to grant/deny access to files based on whether the user has rights to the node to which it is attached/associated. Now, though, only the admin user is able to download private files and everyone else is getting the Access Denied error.

Has anyone else been able to find any other modules that have toxic interactions with the private_upload module?

lejon’s picture

I thought I had this problem as I was trying to access files I had linked to in body text, where I'd set the link through IMCE.

However, when I tried to access them through the file attachment link at the bottom of the page it worked. This means that this module forces you to only access attachments through the "Attachments" list at the bottom of the node, and, as stated above, won't allow you to access a file from a direct link. In that case you have to choose the "list" checkbox when attaching your attachments to a node.

So it may be this that is the problem rather than a module clash.

agerson’s picture

backup_migrate has issues too

http://drupal.org/node/828538

marcoka’s picture

and private_download, too.

firebus’s picture

according to that thread, backup_migrate issues from 6.x-1.x are resolved in 6.x-2.x

gavinengel’s picture

I had a similar problem to one or two people in this thread: user #1 was able to download the file, but not other users. I ended up fixing this by going to /admin/user/permissions, then checking `view uploaded files` for `authenticated users`.

charlie-s’s picture

I am logged in as user1 and receive "You don't have permission to access /sites/default/files/private/filename on this server".

How are permissions set?

Edit: I was printing the link directly as opposed to using the themed link, /system/files/...

New question -- can/should this module alter (or amend) the $node->files object to include a flag denoting whether the file is private or not?

easybuildtech’s picture

GOOD CATCH!!! I have been screwing around with this for a week, disabling modules enabling modules trying to determine the conflict. What was happening was that all of my members would click on a private PDF and then would be asked to re-login. However, for whatever reason, as a superadmin my cookie was different so that I would never see the error on my computer even when I would log in under a non-superadmin. After figuring all that out, disabling confilicting modules and delete my superadmin cookie, I was finally able to determine and fix the problem. Which ended up being printing the link directly...

THANK YOU!!

davedpss’s picture

I am also logged in as user1 and get the "You don't have permission to access.... files/private/...pdf". The links I am creating are in a view. csdco mentions using the themed link and implies that fixed the issue. In the field options in the view I have check the box to link this field to its file. Can someone tell me what I need to do to make it use a themed link versus the direct link it is using.

Thanks.