Page 1 of 1

Code does not execute after header

Posted: Tue Apr 02, 2013 7:18 pm
by inosent1
OK, so i figured out how to upload to the server, and then, using 'header' to save the file to the location of the users choice, with the code below:

Code: Select all


header("Content-type: application/pdf");
    header("Content-Disposition:attachment; filename=" . $file_name);
    header("Content-Length: " . filesize($file_name_));
    readfile("cfiles/" . $file_name);

the only issue is, there is more code afterwards that does not execute, namely a simple re-direct to the page where the call came from in the first place:

Code: Select all


<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=upload.php?file_id=<? echo $file_id; ?>"> 
</head>
</html>

the header forces a save as dialogue box to pop up, which i like, but after i save the file, the refresh does not fire.

how can i make the underlying page refresh after saving the file?

TIA

Re: Code does not execute after header

Posted: Tue Apr 02, 2013 7:47 pm
by requinix
You cannot do both at the same time. If this page really just pops up a download dialog then there shouldn't be any need to redirect to the previous page: the user won't actually have left it.