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!

File download...

Status
Not open for further replies.

deemarcus

Programmer
Aug 18, 2005
21
GB
Hi the following code is part of my php page which displays files in a folder/s. When the user select the file it opens it automatically, can i pass the file to a download page or somthing which will open the file and prompt the user to download>


chdir($path);
$file_location = "files/standard/reports/".basename($current_dir)."/";
echo "<a href=\"$file_location$value\">$value</a>";

Please can anyone help!

Kindest regards,


Dee
 
Hi..
You will need to use header() with attatchment, define document-type, etc.

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');
?>

I took that code from:

I would read up there, if I where you.
Personally, I have made a great "download" script, with "request download", download id's, etc. a system which stores in a table who downloads what, etc.

but, how complex you want it, is all up to you.
no matter how simple you want it, read the examples, comments, requirements, limitations, etc.

good luck, it's not too hard :)

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top