The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Download files by inputting exact filename

Discussion in 'General Discussion' started by AaronV, Nov 28, 2007.

  1. AaronV

    AaronV Registered

    Joined:
    Apr 2, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I know this might be a strange request, but I have a website in which I will be uploading files of work I do for customers. I am trying to figure out how they can download a file without a link - in other words, I will have a text box and button, and they will have to input the exact filename to download it - preferably without the extension, i.e. .pdf or .doc, etc.
    Any help?
    Thanks
    Aaron
     
    #1 AaronV, Nov 28, 2007
    Last edited: Nov 28, 2007
  2. AaronV

    AaronV Registered

    Joined:
    Apr 2, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Maybe this question belongs in a different forum :confused:
     
  3. darren.nolan

    darren.nolan Well-Known Member

    Joined:
    Oct 4, 2007
    Messages:
    259
    Likes Received:
    0
    Trophy Points:
    16
    It's not a cPanel thing, but I can point you in the right direction with PHP & headers.

    http://au.php.net/header

    <?php
    // We'll be outputting a PDF
    header('Content-type: application/pdf');

    // It will be called downloaded.pdf
    header('Content-Disposition: attachment; filename="downloaded.pdf"');

    // The PDF source is in original.pdf
    readfile('original.pdf');
    ?>

    When this file is accessed (say you make this file index.php) - the browser will just start to download your required PDF file. You can of course then make yourself a database for valid users and authenticate them etc. etc.

    The end-user then has no knowledge of where the file is coming from, and it can even "not" be in your document root (/home/username/public_html/).

    Hope this helps.
     
  4. AaronV

    AaronV Registered

    Joined:
    Apr 2, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Exactly! Thanks so much for your help.
     
  5. darren.nolan

    darren.nolan Well-Known Member

    Joined:
    Oct 4, 2007
    Messages:
    259
    Likes Received:
    0
    Trophy Points:
    16
    Okay! :)

    PHP is certainly my forte, so hit me up a PM if you have troubles with it.
     
Loading...

Share This Page