php Header文件下载
/** * 文件下载 * @param string $path 文件所在路径 * @param string $filename 文件名 * * $dir="F:/file/"; $filename="f.txt"; file_down($dir,$filename); */ function file_down($dir,$filename){ $path=$dir.$filename; if(!file_exists($path)){ exit("文件不存在"); } //打开文件 $file = fopen ($path, "r" ); //输入文件标签 Header ( "Content-type: application/octet-stream" ); Header ( "Accept-Ranges: bytes" ); Header ( "Accept-Length: " . filesize ($path ) ); Header ( "Content-Disposition: attachment; filename=" . $filename ); //输出文件内容 //读取文件内容并直接输出到浏览器 echo fread ( $file, filesize ( $path ) ); fclose ( $file ); exit (); }
相关推荐
kentrl 2020-11-10
咻咻ing 2020-07-04
wghou 2020-06-16
zkwgpp 2020-06-14
xiechao000 2020-05-18
woniyu 2020-05-14
ysmh00 2020-05-14
0与的世界 2020-04-28
worldkun 2020-05-10
carolAnn 2020-04-20
zengni 2020-02-29
hygbuaa 2020-02-26
zhaolisha 2020-02-24
server { listen 80; server_name ××××.com; access_log /×××/×××/nginx/log/access.log; error_log /×××/×
咻咻ing 2020-02-02
JF0 2020-01-31
OwenJi 2020-01-17
webfullStack 2020-01-10