header attachment - partial file in IE7 and FF
Posted: Tue Jun 05, 2007 11:52 am
The code below is for a page that is attempting to download a set of results to a rtf file. It works fine, but only in IE6. IE7 and Firefox are causing the file to partially transfer. Word gives me a corrupt file error presumably due to the rtf footer not making it in at the end. I'd say about 75% of the data usually makes it into the file.
Can anyone help me out with what I'm missing here? Am I not correctly declaring the length/size of the file or something?
Any help is greatly appreciated. I exhausted Google with every possible combination of terms I could think of to figure this out.
Code: Select all
$tempdest="/var/www/html/sysrep/reports/$date/$system/$customer/$report";
if (file_exists($tempdest))
{
$expanded = implode("",@gzfile($tempdest));
$firstpagebreak=strpos($expanded,chr(12));
$expanded = substr($expanded,$firstpagebreak+1);
$expanded = str_replace("\n","\n\\par ",$expanded);
$expanded = str_replace(chr(12),"\\page ",$expanded);
header("Content-Descrption: File Transfer");
header("Content-Type: application/force-download");
header("Content-Length: ". strlen($expanded));
header("Content-Disposition: attachment; filename=\"".$_GET["report"].".rtf\"");
readfile("rtfhead.inc");
echo $expanded;
readfile("rtffoot.inc");
}else{
echo "I have no reports for the information provided. Please try again.<br>\n";
}
exit;
?>
Any help is greatly appreciated. I exhausted Google with every possible combination of terms I could think of to figure this out.