[php] <?php //下载文件 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]
简单的下载文件函数
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
centos7用命令上传、下载文件
centos7用命令上传、下载文件
centos linux 上传下载 -
jquery post的请求下载文件 jquery 下载文件流
了解 性能测试工作中,文件上传也是经常见的性能压测任务之一,之前工作中一直使用loadrunner做文件上传与下载压测,近几年开始使用Jmeter做性能测试,那么文件上传下载脚本怎么做,今天分享Jmeter文件上传与下载脚本怎么做. 知识点java文件上传下载代码jmeter脚本中上传与下载java文件目录文件操作复习先学习下ja
jquery post的请求下载文件 jquery 上传文件 jquery 文件上传 jquery上传文件 jquery文件上传