Code does not execute after header

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
inosent1
Forum Commoner
Posts: 97
Joined: Wed Jan 28, 2009 12:18 pm

Code does not execute after header

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Code does not execute after header

Post 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.
Post Reply