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!

Force Download Script....Actions After Execution

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
I'm using the following script to download files from my server. how do you display a message (or can you) after it is done? I tried putting in an echo statement both before and after the code but it never executes.



$filename = 'costos.pdf';
$filename = realpath($filename);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
switch ($file_extension) {
case "pdf": $ctype="application/pdf"; break;
case "doc": $ctype="application/msword"; break;
case "jpg": $ctype="image/jpg"; break;
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: $ctype");
/* header("Content-Disposition: attachment;

filename=\"".basename($filename)."\";");*/
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($filename));
set_time_limit(0);
@readfile("$filename") or die("File not found.");
 
i don't think you can. remember, to download you are setting content-type and other headers other than text/html.

maybe you could do something with javascript and managing the download through a child window.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top