View Full Version : Hide exact download path?
eskimoet
01-30-2008, 08:55 PM
Ahoy, currently building a new site with multiple downloads, but I don't want any users to know the exact download path. How would I go about hiding it?
Thanks
You can use a PHP script to stream the file from a location outside of the web document root.
Having said that I don't have any code to show you or to point you too but I seem to recall a similar answer to this question previously on these forums so you may be able to find one by searching...
eskimoet
01-31-2008, 12:35 PM
Yeah I thought I'd seen one around here but when I looked for it I couldn't find anything.. I guess its just a case of delving deeper into the pit that is old threads and hoping to pull a useful one out of the hat.
Example of readfile() from www.php.net
$file = 'ASDFGgg.pdf';
_Download("files_dir/".$file, $file);
function _Download($f_location,$f_name){
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($f_location));
header('Content-Disposition: attachment; filename=' . basename($f_name));
readfile($f_location);
}
Note that _Download() in this case must be called before any output from page. Depending on what you want to do, you may want to adjust the 'Content-Type' and 'Content-Disposition' headers. The above example will try to force the client's browser to save the file.
eskimoet
01-31-2008, 05:02 PM
Thanks Seb.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.