Hey guys.

I've been looking through the module list but I haven't really found anything to do the following. I have pdf and .doc files I only want users who have account to be able to access. If you click on the file and you don't have an account, it should take you to a login page where you can create an account or login if you're already a member. The files can reside anywhere...as long as I can do the user access thing. Is this possible?

Thanks

Comments

yelvington’s picture

It's a simple configuration setting. Admin -> Site configuration -> Files system.

vm’s picture

user access on the ability to download files uploaded with the upload.module would be controlled in administer -> access control , remove anon user rights to see the "view" the file uploads under upload module.

if you are using something other than the upload.module to upload files you will need to inform is what module is handling the uploads you are trying to control.

The user above is dicussing the private vs. the public download method. this would also work disallowing anyone not logged into not be able to download files.

hello12345’s picture

Well here's a run down of what I have:

I have pages on my website which link to a file a folder on the site. Are you saying the above methods will allow someone to register for an account once and they will be able to have access to that file? I'm more worried about anonymous users...I'd like for them to come to a page that says you need to login or create an account when they click on the link of the file. That should clear things up. I'm not uploading anything, I merely place the files I want available into a folder.

Mike

vm’s picture

unless you are using one of the drupal methods of uploading there is no control method for Drupal to control the downloading of files you link to on your content that I am aware of.

hello12345’s picture

I'm not really uploading anything...The files are already in the drupal folder called "downloads".

There's got to be something that will only let members with an account to download the files, and if they don't have an account or they aren't logged in it should take them to a login page.

Seems pretty simple..

It doesn't have to be a module, just something that will allow this to work.

Anyone know how to do this?

Mike

vm’s picture

because they weren't uploaded with Drupal they are not in the database and can't by pulled from the database.

Thus you can create a page, and manually link to the files using HTML, once the databse is bypassed, your ability to be dynamic is also bypassed.

hello12345’s picture

Currently, we have in place a file_download module someone created that requires someone to input their name and email address then pulls the file name and request from the database. Then this person is emailed a link, with a link to the file from /files/filename.pdf

Obviously this is totally different then what I want to do.

1.) People should be able to register an account through my drupal site
2.) With this account they will be able to download an unlimited amount of files.
3.) If they aren't logged in or registered and they try to click on a download link they will see a login page.

So my questions are:

How can I use Drupal's file system and upload modules to do the three things above?
If someone could point out exactly what I have to do...that would be much appreciated.

Thanks,

Mike

vm’s picture

A) reupload all the files through Drupal. Be it with the upload.module which is part of core, or possibly the webfm.module (file manager) which is a contrib download.

B) then assign permission to authenticated users to be able to access content and download files. in administer -> access control

or

if you don't want to upload them all again, create a content type like "page" and link all your files to it, and only allow this page to be seen by authenticated users.

hello12345’s picture

Ok all the files have now been uploaded by the drupal module and if you are logged in you can access them.

However, if you are not logged in or don't have an account through my website you get the following error:

http://www.chazcast.com/page.jpg

How can I have that error page tell the user that they need to login first or make an account in order to access the files including a login box and register button?

Thanks,

Mike

cookiesunshinex’s picture

I have exactly this same need.

I want the error page to provide a login/registration box, or at least tell them that they need to login to download these files, instead of just telling them that they don't access.

hello12345’s picture

Hey cookiesunshinex,

What I did was,

1.) Install the Custom 404/Error Module
2.) Add the following code to the 404 page you assigned to the custom error module:

<?php

global $user;
if ($user->uid) {
print l("Log Out " . $user->name,"logout");
} else {
print drupal_get_form('user_login_block');
}
?>

The only problem with doing it this way, is that when you legitamitly have a file missing or wrong path name, you get a login box instead of a 404 error page. The user might think they need to login in order to get the file, when in actuality it's leading them somewhere totally different.

Mike

somethingorother’s picture

You can create custom error (404 and 403) pages and place a link to your login page.

Here's some directions:

http://drupal.org/node/120646

Qudsiyya’s picture

Hi,

I am facing the same problem. I could not solve it using the suggestions presented to you.

I have a page with links to download files. I have uploaded the files through the upload module. I have give the anonymous user the rights to view the content but not to view the uploaded content.

Here is the situation

When the anonymous user clicks on this particular page he is able to view the content but not the links to download. I want the links to be visible to him but only when he tries to click on them the error page or the login page should show up.

Please share how you were able to solve the problem.

Regards,

hello12345’s picture

First,

Do you want an anonymous user to be able to download uploaded files or just authenticated users?

In my setup, anonymous users can view the download links but if they try to click the link and they are not authenticated, they will see a login/register page.

I set this up by doing the following.

First, using the upload module, upload the files to a page that isn't being used. Then you'll be able to recognize what the exact download links are.

Next, install the custom 404 page module and insert the below code into the custom 404 page you are creating.


<?php

global $user;
if ($user->uid) {
print l("Log Out " . $user->name,"logout");
} else {
print drupal_get_form('user_login_block');
}
?>

As for permissions,

Make sure only authenticated users can view uploaded files. Also make sure you are using the private download method.

That should be about it. Let me know if you get this working or not.

Qudsiyya’s picture

Hello,

I still could not get it working. When ever I access the page as an anonymous user I only see the regular text and no links.

Please find my answers inline.

Do you want an anonymous user to be able to download uploaded files or just authenticated users?

I want the anonymous user to view the download links and register in order to download i.e. he sees a login/register page when tries to click on the download link.

First, using the upload module, upload the files to a page that isn't being used. Then you'll be able to recognize what the exact download links are.

I created a page. Added some text and uploaded three files using the upload module.

Next, install the custom 404 page module and insert the below code into the custom 404 page you are creating.

I installed the custom 404 page module and pasted the code into the description of 404 page at
site configuration -> custom error

Make sure only authenticated users can view uploaded files.
Yes i did that

Also make sure you are using the private download method.
Yes i did that

Your help is very appreciated
Regards,

hello12345’s picture

I still could not get it working. When ever I access the page as an anonymous user I only see the regular text and no links.

Hi,

After you uploaded your files on the seperate page, did you take note of what the download link is?
Once you know what the link to the file is, you can simply post this link on any page you want. When an anonymous user clicks this link, they will encounter the login/register page.

Mike

Qudsiyya’s picture

Hi,

Thanx I got it working this time. I wasn't pasting the download links in the body of the page. I was just uploading the files. That is why i wasn't able to view the links as an anonymous user.

Regards,
Qudsiyya

dcoun’s picture

Similar problem that made me to start creating a module: http://drupal.org/node/152425
The idea is that you have uploaded files within a drupal node as attachment and you want the text part of the node to be visible by everyone (or by certain roles through e.g. TAC) but the attachment(s) to be accessed by certain roles only. if the user has not access to download it, a denied access page by drupal is shown. The same can be happen with files uploaded (outside drupal) by an other filemanager in drupal files directory.

Qudsiyya’s picture

Looking forward to it

Regards,

japo32’s picture

node access module.

adrian domingo

http://www.lucid.ph