-1

我有从服务器下载种子文件的脚本:

header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private");
        header("Content-Description: File Transfer");
        header("Content-Type: application/x-bittorrent");
        header('Content-Length: '.filesize($local));
        header("Content-Disposition: attachment; filename=\"".$local."\"");
        $file = fopen($local, "r");
        print fread($file, filesize($local));
        fclose($file); 

如果我下载文件,torrent 已损坏且无法使用,任何人都可以帮助我吗?错误是:

Torrent文件解码失败!请尝试重新下载种子!

编辑:

$path = 'torrent/'; 
$local = $path.$row['file_src']; 

我做些小改动

header('Cache-control: private');
    header('Content-Type: application/x-bittorrent');
    header('Content-Length: '.filesize($local));
    header('Content-Disposition: filename='.$download);
    $file = fopen($local, "r"); 
    print fread($file, filesize($local)); 
    fclose($file);

编辑: 抱歉,但总的来说这不是问题,谢谢@deceze,问题出在 torrent 文件中,下载后有一行。我怎样才能修复这个?

4

1 回答 1

-1
  header("Content-Disposition: attachment; filename=\"".$local."\"");

这一行是一个问题,因为您的标题文本被包裹,"但您的文件名子部分也被包裹,"因此代码将无法理解使用相同引号的两个层,因此将其更改为:

  header("Content-Disposition: attachment; filename='".$local."'");

这维护了标头的报价结构。

于 2015-07-04T09:24:26.107 回答