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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Download Manger - Header -> Save AS?

Status
Not open for further replies.

Trancemission

Technical User
Oct 16, 2001
108
GB
I am looking at creating a simple download script for my site. Currenlt I am looking to use a similar system to sourceforge where you choose your mirror and then goto a page and 5 seconds later your file is sent to you.

The key thing I am looking for is security - my files for download are tracked in a database for downloading. I do not want the files to be stored under the root of my website ie:

/home/USERNAME/FILES_HERE

and webroot is:

/home/USERNAME/www/

so I redirect to a page with a file_id, i check the DB for that file, check user has access and the redirect the user to download the file.

The key is that the end user cannot simply type in the filename in their web browser. I do not want to use .htaccess to control access.

Any help/poiters appreciated.

Trancemission
=============
If it's logical, it'll work!
 
ALl you need to do is open the file via a file handle and stream it after sending the appropriate headers.
There are examples in the PHP manual, e.g.
Code:
<?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');
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top