傻蛋他哥

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

function download_file($file,$showname){
if(is_file($file)){
$length = filesize($file);
$type = mime_content_type($file);
header("Content-Description: File Transfer");
header('Content-type: ' . $type);
header('Content-Length:' . $length);
if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) {
header('Content-Disposition: attachment; filename="' . rawurlencode($showname) . '"');
} else {
header('Content-Disposition: attachment; filename="' . $showname . '"');
}
readfile($file);
exit;
} else {
exit('文件已被删除!');
}
}

posted on 2013-10-28 16:20  傻蛋他哥  阅读(162)  评论(0编辑  收藏  举报