您的位置:首页 > 编程语言 > PHP开发

php文件下载函数

2015-10-05 23:10 666 查看
<?php
/**
*Fil_download
*$path 要下载的文件路径
*$type 要下载的文件类型
*/
function Fil_download($path,$type = 'zip')
{
if(!file_exists($path))
{
return false;
}else{
$file = fopen($path,'r');
header('Content-Type: application/'.$type);
header('Content-disposition: attachment; filename='.basename($path));
header('Content-Length: '.filesize($path));

echo fread($file,filesize($file_dir));
fclose( $file );
exit ();
}
}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: