是一个动态php文件我把phpheader代码写进去但是打开这个动态页面的时候能获取到文件路径并且把这个文件.zip依html方式的打开了全是乱码请问怎么才能使打开这个页面弹出点击弹出下载而...
是一个动态php文件 我把php header 代码写进去 但是打开这个动态页面的时候能获取到文件路径 并且把这个文件.zip依html方式的打开了 全是乱码
请问怎么才能使打开这个页面 弹出点击弹出下载 而不是把这个.zip文件依html方式打开
error_reporting(0);
$referer = $_SERVER['HTTP_REFERER'];
$selfurl = $_SERVER['HTTP_HOST'];
/*
if(false == strpos($referer,$selfurl))
{
die(" Request Error.! ");
exit(1);
}
*/
require_once(dirname(__FILE__)."/../include/common.inc.php");
require_once(DEDEINC.'/download.class.php');
$t1 = ExecTime();
if(empty($okview))
{
$okview = '';
}
if(isset($arcID))
{
$aid = $arcID;
}
$arc = new Archives($aid);
if($arc->IsError)
{
ParamError();
}
$arc->Display();
if(isset($arcID))
{
$aid = $arcID;
}
$arcID = $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
if($aid==0)
{
die(" Request Error! ");
}
$row = $dsql->GetOne("Select * From `#@__icons` where aid='$aid' ");
$str = $row['icodown'];
if(substr_count($str,"/uploads/soft/")>0){
$file = ltrim($str,"/uploads/soft/");
$link = "<?php echo $cfg_basehost; ?>";
$url = "".$link."".$file."";
//echo "$url";
$get_url = urldecode($url);
$file_name = basename($get_url);
$get_url = "../uploads/soft/" . $file;
ob_end_clean();
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename='.'123_'.$file_name);
header('Content-Length: '.filesize($get_url));
error_reporting(0);
readfile($get_url);
flush();
ob_flush();
exit;
}else{
$get_url = urldecode($str);
$file_name = basename($get_url);
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename='.'123_'.$file_name);
header("Connection: close");
readfile($get_url);
}
exit;
?>
为什么不弹出下载 而是直接把这个zip的内容打印出来了
展开