$FileName = "file";
$File = "pathway/".$FileName;
if(is_file($File)){
if(strstr($HTTP_USER_AGENT, "MSIE")){
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$FileName.'"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Content-Transfer-Encoding: binary");
header('Pragma: public');
header("Content-Length: ".filesize("$File"));
}else{
header("Content-type: file/unknown");
header("Content-Length: ".filesize("$File"));
header("Content-Disposition: attachment; filename='$FileName'");
header("Content-Description: PHP3 Generated Data");
header("Cache-Control: cache, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
}
$fp = fopen($File, "rb");
fpassthru($fp);
fclose($fp);
}
2012-01-27
Source code for download file with PHP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment