1

I am developing one feature in which user will get one pdf from my site, for this I have developed a process below,

1) user will click on the link and form open in popup

2) after submitting the form one link will be sent to his email address

3) when user clicks on the link one small process of token check will be done and he will get the file

4) second time this link will not work

This whole process is working fine here my question is I want to restrict the user to get my files when user directly hit the URL link like www.mysite.com/files/downloads/abc.pdf

users can only be able to download it through that link which is in Email.

Thanks for advance.

2 Answers 2

0

Not sure if this will help you, as I have never used it, but worth checking out:

Unique-download

Onetime download link is useful to create one-time download link, similar to one time login. This will be helpful to send users one time download links for e-commerce or download entities such as books, mp3 etc etc. considering them as file attachment for initial development.

0

My suggestion is,Don't get access direct file Url to users, Register a menu (with hook_menu) something like download/% in menu callback check accessibility also you can check where is request source('HTTP_REFERER') and etc. you finally if it authorized passed file to him with something like ( because you told that you are a developer, I get you a clue How to achieve this job)

    $attachment_location = $_SERVER["DOCUMENT_ROOT"] . "/file.zip";
    if (file_exists($attachment_location)) {

        header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
        header("Cache-Control: public"); // needed for internet explorer
        header("Content-Type: application/zip");
        header("Content-Transfer-Encoding: Binary");
        header("Content-Length:".filesize($attachment_location));
        header("Content-Disposition: attachment; filename=file.zip");
        readfile($attachment_location);
        die();        
    } else {
        die("Error: File not found.");
    } 

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.