php 弹出文件下载 原理 代码 /** * @author default7 * @description 演示php弹出下载的原理 * * @param $file_name */function downfile($file_name){ $file_path = /tmp/ . $file_name; $buffer = 102400; //一次返回102400个字节 if (!file_exists($file_path)) { echo ; return; } $fp = fopen($file_path, r); $file_size = filesize($file_path); $file_data = ''; while (!feof($fp)) { $file_data .= fread($fp, $buffer); } fclose($fp); //begin writing headers header(pragma: public); header(expires: 0); header(cache-control: must-revalidate, post-check=0, pre-check=0); header(cache-control: public); header(content-description: file transfer); header(content-type:application/octet-stream;); header(accept-ranges:bytes); header(accept-length:{$file_size}); header(content-disposition:attachment; filename={$file_name}); header(content-transfer-encoding: binary); echo $file_data;}
http://www.bkjia.com/phpjc/871201.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/871201.htmltecharticlephp 弹出文件下载 原理 代码 /** * @author default7 * @description 演示php弹出下载的原理 * * @param $file_name */function downfile($file_name){ $file_path = /tmp/...