<?php
 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;
?>
这段代码能正确的获取文件位置 但就是把文件依html方式给打开了 就好像是.zip文件用html方式打开 全乱码我想要直接打开这个php文件 然后弹出下载文件 而不是把这个.zip文件依html方式打开~~~ 谢谢

解决方案 »

  1.   

    还是先把 error_reporting打开看看报什么错再说。
      

  2.   

    那只能说明readfile($get_url);中的参数路径不正确,或者不存在。
    将其打印出来
      

  3.   


    你好 我开始也觉得 路径不对 但是我放一了个 .txt文件上去 然后再打开这个页面 发现能读取到这个.txt文件中的东西