php 文件下载出错
写了一个 文件下载的程序
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->function download_file($filename){
//below to provide the download
if (file_exists($filename)) {
$file = fopen($filename);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($filename));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename) . ' bytes');
//ob_clean();
//flush();
readfile($filename);
fclose($file);
return true;
}else{
echo("the file not exist");
return false;
}
//above to provide the download
}
if(download_file($filename)){
#下面的操作
}else{
#错误提示
}
<br><font color="#e78608">------解决方案--------------------</font><br>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号