改文件后缀。没别的办法。WEB服务器一看是PHP的请求就会做处理的。

解决方案 »

  1.   

    点击下载链接,提交给这个php
    <?php
    download_file("../../../challenge/config/csv/C_0001.csv");
    exit();
        
        
    function download_file($path_file){
    ini_set('max_execution_time', 600);
         if (!file_exists($path_file)) {
             die("Error: File(".$path_file.") does not exist");
         }
         if (!($fp = fopen($path_file, "r"))) {
             die("Error: Cannot open the file(".$path_file.")");
         }
         fclose($fp);     if (($content_length = filesize($path_file)) == 0) {
             die("Error: File size is 0.(".$path_file.")");
         }     header("Content-Disposition: inline; filename=\"".basename($path_file)."\"");
         header("Content-Length: ".$content_length);
         header("Content-Type: application/file");     if (!readfile($path_file)) {
             die("Cannot read the file(".$path_file.")");
         }
         ini_set('max_execution_time', 30);
    }?>
      

  2.   

    是不是在上传时该文件的后缀,把我解析出来的后缀名$pieces,该成什么呢?
      

  3.   

    $path_file 是不是我下载的文件“/fname/<?php echo $data[upname];?>,   ????????
      

  4.   

    就是你要下载的文件(带PATH)。
      

  5.   

    我是这样写的 :<?php
    download_file("../../../challenge/config/csv/C_0001.csv");
    exit();
        $path_file = "/usr/www/html/sinobone/fname/$data[pic_name]";
        function download_file($path_file){
    ini_set('max_execution_time', 600);
         if (!file_exists($path_file)) {
             die("Error: File(".$path_file.") does not exist");
         }
         if (!($fp = fopen($path_file, "r"))) {
             die("Error: Cannot open the file(".$path_file.")");
         }
         fclose($fp);     if (($content_length = filesize($path_file)) == 0) {
             die("Error: File size is 0.(".$path_file.")");
         }     header("Content-Disposition: inline; filename=\"".basename($path_file)."\"");
         header("Content-Length: ".$content_length);
         header("Content-Type: application/file");     if (!readfile($path_file)) {
             die("Cannot read the file(".$path_file.")");
         }
         ini_set('max_execution_time', 30);
    }
    ?>
        <a href = "/fname/<?php echo urlencode($data[pic_name])?>" target=_blank>
    [更多内容上传、请点击此处下载查看]</a> 它产生这样的错误:
      Fatal error: Call to undefined function: download_file()
      

  6.   


    download_file("../../../challenge/config/csv/C_0001.csv");
    exit();放到最后不然exit();了就无法调用后面的函数了
      

  7.   

    给你写了个sample,自己看看再对着改。
    1.sample.html
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312">
    <!--- <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">  --->
    <title>sample</title>
    <SCRIPT language="JavaScript">
    <!--
    function send(filename){
        document.formMain.downloadfile.value = filename;
        document.formMain.action = "sample.php";
        document.formMain.submit();
    }
    //-->
    </script>
    </head><body topmargin="5" bgcolor="#ffffff">
    <form name="formMain" method="post">
    <input type="hidden" name="downloadfile">
    <P align=center><B><A href="javascript:send('abc.jpg');">download</A></B></P>
    </form>
    </BODY>
    </HTML>
      

  8.   

    2.sample.php<?php
    download_file("/abc/fku/html/sxye/sinobone/fname/".$_POST["downloadfile"]); function download_file($path_file){
    ini_set('max_execution_time', 600);
         if (!file_exists($path_file)) {
             die("Error: File(".$path_file.") does not exist");
         }
         if (!($fp = fopen($path_file, "r"))) {
             die("Error: Cannot open the file(".$path_file.")");
         }
         fclose($fp);
         if (($content_length = filesize($path_file)) == 0) {
             die("Error: File size is 0.(".$path_file.")");
         }
         header("Content-Disposition: inline; filename=\"".basename($path_file)."\"");
         header("Content-Length: ".$content_length);
         header("Content-Type: application/file");
         if (!readfile($path_file)) {
             die("Cannot read the file(".$path_file.")");
         }
         ini_set('max_execution_time', 30);
    }
    ?>
      

  9.   

    to  zhuomaocn(烦啊) 
    你的这个也是直接打开的.