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

PHP下载文件步骤实例教程

2024/4/2 10:04:38发布31次查看
php下载文件方法实例教程
php下载文件的两种方法与代码分享
转自:http://www.cnblogs.com/cfinder010/p/3197195.html
php实现下载文件的两种方法。分享下,有用到的朋友看看哦。
方法一:
php/*** 下载文件* header函数**/header('content-description: file transfer');header('content-type: application/octet-stream');header('content-disposition: attachment; filename='.basename($filepath));header('content-transfer-encoding: binary');header('expires: 0′);header('cache-control: must-revalidate, post-check=0, pre-check=0′);header('pragma: public');header('content-length: ' . filesize($filepath));readfile($file_path);?>
以上代码用到了php header函数,可以参考以下如下的文章:php header()函数的简单例子php header函数实现文件下载的实例代码php中header函数的用法举例详解php header 使用详解php header函数 文件下载时直接提示保存的代码php header函数实现文本文件下载的方法php 文件头部(header)信息详解php使用header发送各种类型文件下载的例子了解php中header函数的用法。
方法二:
php//文件下载//readfile$fileinfo = pathinfo($filename);header('content-type: application/x-'.$fileinfo['extension']);header('content-disposition: attachment; filename='.$fileinfo['basename']);header('content-length: '.filesize($filename));readfile($thefile);exit();?>
该用户其它信息

VIP推荐

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