Download files by inputting exact filename

AaronV

Registered
Apr 2, 2004
4
0
151
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
 
Last edited:

darren.nolan

Well-Known Member
Oct 4, 2007
257
0
66
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.