本帖最后由 u013293559 于 2014-02-10 12:11:05 编辑

解决方案 »

  1.   

    如果没有防盗链就header Location可以了
      

  2.   

    这个也要举例啊?
    <?php
    /* This will give an error. Note the output
     * above, which is before the header() call */
    header('Location: http://www.example.com/');
    exit;
    ?>
    就手册上的例子,可以写成
    header('Location: $url'); //$url 自己处理如何获得
      

  3.   

    如果类似php这类。。应该不能下载吧。。
    下载以后也是html的
      

  4.   

    亲,php文件是不能下载的,只能下载一些前端的文件 比如:html,js,css
      

  5.   

    我好想没说明白  我的意思是  服务器上有个文件或者压缩包  可以得到路径 想把这个文件下载下来    用 php代码怎么写
      

  6.   

    ……
    看样子是作为客户端用
    比较简单就是file_get_contents($url)然后fwrite到本地一个文件
    复杂点就curl
      

  7.   

    header('Content-Disposition:attachment;filename=test.php');
    readfile('a.php');//目标文件
      

  8.   


    <?php
    $file_dir = '';//定义文件路径
    $file_name = '';//定义文件名字
    $file = fopen($file_dir . $file_name,"r"); // 打开文件
    Header("Content-type: application/octet-stream");
    Header("Accept-Ranges: bytes");
    Header("Accept-Length: ".filesize($file_dir . $file_name));
    Header("Content-Disposition: attachment; filename=" . $file_name);
    // 输出文件内容
    echo fread($file,filesize($file_dir . $file_name));
    fclose($file);
    exit();
    ?>