Rumah >pembangunan bahagian belakang >tutorial php >php 文件下载失误
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>