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

Forced Anonymous Download Link

Status
Not open for further replies.

bont

Programmer
Joined
Sep 7, 2000
Messages
200
Location
US
Hello all. I am trying to make a script(s) that can handle a few tasks:

1) Supply the user a list of links for files that match a mysql query.
2) The links should not reveal the actual location of the file.
3) The user should be forced to download.

Now I have found some tid-bits here and there but I have no examples go by. I would like to address each separately.

1 --
This is the toughest to find what I am looking for. From the MySQL DB I'd like to display the filename and description, maybe some other erata found in the DB.

2 --I would like the location secret. If anyone has an example of this I would be greatly appreciative. I have seen some that use arrays to use an include file for db connection. I would love an example of this that would show the highlights.

3 -- This I believe may be done using a setting on the page for the file type.

Thank you for your help.
 
In order to keep the file locations secret, you're going to have to interpose a PHP script between your user and the files.

Create a script that, given some definitive input of your design, can open a file and stream it to the browser.

In terms of forcing a download, just sending the file to the browser downloads it. To force the browser to present a "Save as" dialog, send the HTTP headers:

Content-type: application/octet-stream;
Content-Disposition: attachment; filename=<thefile.name>

Want the best answers? Ask the best questions: TANSTAAFL!!
 
I have seen this term &quot;stream&quot; a few times. And I have seen some samples where they use fopen etc to appear to make a copy. I will be dealing with binary 100MB+ files. This may not be very pheasible. Or do I have wrong idea? Does anyone have an example of streaming that works well with large files?
 
If you want file anonymity, you're going to have to put up with the overhead. Some process must be interposed between the user and the files.

You can minimize the overhead by using something like PHP's readfile() ( function. It just opens the file and sends it out to the output buffer.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
You could also use fpassthru which is actually intended for this kinda thing.

Still you might into max execution time issues. Raising the max execution time would be the only solution then.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top