OK, this is a strange one, and any help is greatly appreciated. If my File Explorer is already open and showing the folder where my file is saved, after the download, it will show size of 0 bytes. If I force a refresh (or leave the folder and come back) the filesize is accurate. Here is the really odd part…the code below USED to run in a separate browser window, (client side code was forcing a new browser to open before calling the page). It behaved properly for windows file explorer then. However, not opening a separate window is very attractive for several reasons (which I will not go into here).
I am assuming that I am missing something in either the Headers or at the end to notify the client that the send is complete, but I can’t imagine what.
Here is the code:
[code=php]<?
$filename = ‘FubNewSignature090601.jpg’;
$pathtofile = ”;
$extpos = strrpos($filename, “.”);
$extension = substr($filename, $extpos+1);
header(‘Content-Description: File Transfer’);
if ($extension == “jpg” || $extension == “jpeg”) {
header(‘Content-type: image/jpeg’);
} elseif ($extension == “bmp”) {
header(‘Content-type: image/bmp’);
} elseif ($extension == “png”) {
header(‘Content-type: image/png’);
} else {
header(“Content-type: application/octet-stream”);
}
header(“Content-Disposition: attachment; filename=$filename”);
header(‘Content-Transfer-Encoding: binary’);
header(‘Expires: 0’);
header(‘Cache-Control: must-revalidate, post-check=0, pre-check=0’);
header(‘Pragma: public’);
header(‘Content-Length: ‘ . filesize($pathtofile.$filename));
ob_clean();
flush();
readfile($pathtofile.$filename);
exit;
?>
Thanks in advance for any help ?