您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP强制下载PDF文件的代码

2026/2/5 13:41:26发布8次查看
function forcedownload($filename) {if (false == file_exists($filename)) {
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强制下载文件。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product