其实就是将你的的文件,通过二进制的方法,转成流文件让浏览器识别,或者替换头部信息的方式
function downFileFromServer($showFileName, $downFilePath) { if(file_exists($downFilePath)) { if(is_readable($downFilePath)) { if(Trim($showFileName) == '') { $showFileName = 'undefined'; } ob_start(); ob_clean(); $file_size = filesize($downFilePath); header('Content-Encoding:none'); header('Cache-Control:private'); header('Content-Length:' . $file_size); header('Content-Disposition:attachment; filename=' . $showFileName); header('Content-Type:application/octet-stream'); readfile($downFilePath); ob_flush(); } } } //Sample downFileFromServer($fileurl, 真实文件地址);