...

View Full Version : How to redirect url after file download.



mkowen
01-12-2006, 03:02 AM
Hi,

I want to redirect url after file download, now I have the following script:


<?
include("refcode.php");

if(false!=file_exists("./up/".$ups[$_POST['code']]))
{
$file_dir = "./updir/";
$myFileName=$ups[$_POST['code']];

$file = fopen($file_dir.$myFileName,"r");
if (!$file)
{
show_msg("File not open.");
}
else
{
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=" . $myFileName);
while (!feof ($file))
{
echo fread($file,50000);
}
fclose ($file);
show_msg("Download sucessfully.");
}
}
else
{
show_msg("File not existed.");
}

function show_msg($msg)
{
include("error.php");
exit();
}
?>

The file "error.php" is used to display some information about download.The function show_msg is responsible for display the message in a new page.

Now the file can be downloaded sucessfully, but the problem is that show_msg does not execute after file download.

I think it may be caused by "Header", but I'm not sure.

Can anyone help me to figure it out?

Thanks.

rlemon
01-12-2006, 08:38 PM
is it not entering the function?
can you put die("function entered"); right after the start of the function to see?

i don't see setting header output stopping the function from being called.

when all this happens check the source to see if it's a php error. sometimes they don't show up on the page. :S



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum