Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to hide URL path of multiple downloads

Status
Not open for further replies.

feartetsuo

Technical User
Dec 21, 2004
3
US
Hello, I will have multiple downloads on my site, but I do not want the full path to the download to be shown. I know you can do it with PHP but I am a noob when it comes to PHP. I want to set up the downloads like download.php?file=fileToDownload. Thanks.
 
Set up a database table that contains the urls of your downloads.
The table should contain columns for a unique ID and the file URL.

The links for the files would be something like:
downloads.php?id=007

Then create a "downloads" script that contacts the database and redirects to the correct url based on the unique ID passed to it in the link.


- Web design and ranting
- Day of Defeat gaming community
"I'm making time
 
You can also stream the file to the user and build up some sort of array for the files you have.

Your array could be based on something as simple as a dirlist-script, or maybe as suggested above, use a database to store information and path about the files.

you then use header to attatch the file.

Olav Alexander Mjelde
Admin & Webmaster
 
Thanks for the help. I finally got it working with this code:
<?
$files=array(array (../media/FILENAME.zip', 'FILENAME.zip'),

$file=(int)$_GET['file'];

if (strtolower(substr($files[$file][0],0,7))!=' {
if (!is_file($files[$file][0]))
{
header('HTTP/1.0 404 Not Found');
exit();
}

header('Content-Length: '.filesize($files[$file][0]));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$files[$file][1].'"');
readfile($files[$file][0]);
} else header('Location: '.$files[$file][0]);
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top