日期:2014-05-17 浏览次数:20452 次
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{ #错误提示 }
------解决方案--------------------