<>
I've gotten this one report of having a problem downloading a PDF:

"I have tried twice, both times its starts to download but stops about half way or three-quarters the way complete. I get a error message that the download was not completed. When I go to look at the message there is just numbers. I have tried to download again but the "numbers" show up and it won't let me try again."

This only happens for this person with one file - the rest of the files work fine. I am streaming the file with this code:


// will return FALSE if the file is not found // will not return anything if the file is found because the headers should // have already been sent. function streamfile($file) { if (file_exists($file)) {

$extension = strtolower(stristr($file, "."));
if ($extension == ".php" || $extension == ".html" || $extension == ".htm" || $extension == ".shtml") {
include ($file);
}
else if ($extension == ".txt")
{
?>
<html>
<body>
<pre>
<? include($file);?>
</pre>
</body>
</html>
<?
}
else {


// a switch would be perfect here,
// but it just didn't work last time...it was always
// taking the 'default:' case
if ($extension == ".doc"){$type = "application/msword";}
else if ($extension == ".pdf"){$type = "application/pdf";}
else if ($extension == ".exe"){$type = "application/octet-stream";}
else if ($extension == ".ppt"){$type = "application/vnd.ms-powerpoint";}
else if ($extension == ".xls"){$type = "application/vnd.ms-excel";}
else if ($extension == ".xml"){$type = "text/xml";}
else if ($extension == ".zip"){$type = "application/zip";}
else if ($extension == ".txt"){$type = "text/plain";}
else {
$type="application/octet-stream";
}


header("Content-Type: " . $type);
header("Accept-Ranges: bytes");
header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=".basename($file).";"); //readfile($file); $fp = fopen($file, 'rb');
$buffer = fpassthru($fp);
fclose($fp);
exit(); } return TRUE;


}
else
{
return FALSE;
} }



Anyone have any ideas? It would be appreciated.

Scott

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to