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

auto file download

Status
Not open for further replies.

axman505

Technical User
Jun 20, 2001
489
US
Hello,

I have a script which creates a csv file and then provides a link on a webpage to download it. What i want to do, is have the webpage automatically initiate the download process so all the user has to do is click the ok box and select where to download it.

What is the best way to do this? Thanks.
 
Once the file is created send the appropriate headers with the appropriate content type (usually application/octet-stream).
Example:
PHP Manual said:
<?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