return false; }// http headers
header('content-type: application-x/force-download'); header('content-disposition: attachment; filename=' . basename($filename) .''); header('content-length: ' . filesize($filename));// for ie6
if (false === strpos($_server['http_user_agent'], 'msie 6')) { header('cache-control: no-cache, must-revalidate'); } header('pragma: no-cache');// read file content and output
return readfile($filename);; }
复制代码
说明:以上实现一个函数forcedownload(),然后通过调用该函数即可实现php强制下载文件。
