PHP下载文件

浏览2116
 /**
  *文件下载
  *@param $filepath源文件路径 
  */
 function dwon_file($filepath){
 	if(file_exists($filepath)){
 		header('content-type:text/html;charset=utf8');
 		header('Content-Description: File Transfer');
 		header('Content-Type: application/octet-stream');
 		header('Content-Disposition: attachment; filename='.basename($filepath));
 		header('Content-Transfer-Encoding: binary');
 		header('Expires: 0');
 		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
 		header('Pragma: public');
 		header('Content-Length:'.filesize($filepath));
 		readfile($filepath);
 		return true;
 	}else{
 		return false;	
 	}
 }

  • 暂无任何回答