Thread: PHP Gurus
View Single Post
Old 07-15-2006, 07:33 AM  
Damian_Maxcash
So Fucking Banned
 
Join Date: Oct 2002
Location: MaxCash.com
Posts: 12,745
Quote:
Originally Posted by qw12er
I'm using this function to send a file to my users :

function send_file($name) {
ob_end_clean();
$path = $name;

if (!is_file($path) or connection_status()!=0) return(FALSE);
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Content-Type: application/octet-stream");
header("Content-Length: ".(string)(filesize($path)));
header("Content-Disposition: inline; filename=$name");
header("Content-Transfer-Encoding: binary\n");

if ($file = fopen($path, 'rb')) {
while(!feof($file) and (connection_status()= =0)) {
print(fread($file, 1024*8));
ob_flush();
}
fclose($file);
}
return((connection_status()= =0) and !connection_aborted());
}


But for some reason if I try to open it without saving it on my disk it will causes an error. (Invalid Zip file) But if I save the file first and then open it everything works just fine.

How can I fix that ?

Im not totally sure - but I think it could be the mime type setting in your apache config file that is the issue. That could be a start for you to Google from - but I could be way off.
Damian_Maxcash is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote