mkowen
01-12-2006, 02: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.
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.