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

PHP实现简单的文件下载通用方法

2025/12/1 10:11:46发布32次查看
function download_file($file){ if(is_file($file)){ $length = filesize($file); $type = mime_content_type($file); $showname = ltrim(strrchr($file,'/'),'/'); header(content-description: file transfer); header('content-type: ' . $type); header('content-length:' . $length); if (preg_match('/msie/', $_server['http_user_agent'])) { //for ie header('content-disposition: attachment; filename=' . rawurlencode($showname) . ''); } else { header('content-disposition: attachment; filename=' . $showname . ''); } readfile($file); exit; } else { exit('文件已被删除!'); }}
复制代码
php
该用户其它信息

VIP推荐

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