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

Redirect after readfile

Status
Not open for further replies.

AlanArons

Programmer
Aug 1, 2002
91
US
I have a routine to download a file that downloads OK. After the download, I want to redirect the user to another page. The following code seems to stop processing after the readfile statement. Anyone have any thoughts

header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Length: ".filesize($downloadFile));
header("Content-Disposition: attachment; filename=".basename($downloadFile).";");
header("Content-Transfer-Encoding: binary");
readfile("$downloadFile");
header("Location: wndadmin.php");

Thanks for your input

Alan Arons [ponder]

 
because the readfile() effectively stops the headers and starts the content. once content (any content) has been sent you cannot send any more headers.
 
Is there a way then to redirect to a success page? Or is there an alternative to the download sequence I am using?

Alan Arons [ponder]
 
you could use javascript i guess. the download would have to be triggered by js too. but it's a bit odd: the user knows whether a download is successful. why does the developer need to tell him again?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top