通过php下载.torrent文件,无效的Bencoding

时间:2016-06-06 09:16:47

标签: php file header torrent

我正在编写一个自定义php应用程序,应该允许下载torrent文件。 文件位于服务器上,根据用户请求,我按以下方式提供文件:

    if( file_exists( $torrent_file ) ) {
        header("Content-type: application/x-bittorrent");
        header('Content-Length: ' . filesize( $torrent_file ));
        header('Content-Disposition: attachment; filename="' . basename( $torrent_file ).'"');

        readfile($torrent_file);
    }

但是当我下载并尝试将文件添加到uTorrent时,我看到以下错误:

无法加载 - Torrent无效Bencoding。

我四处寻找解决这个问题的方法,但没有任何成功。

1 个答案:

答案 0 :(得分:0)

经过近一天的搜索和谷歌搜索,我发现了问题。 似乎在关闭的php标记之后有一个尾随空格,在其中一个包含的php文件中。 我删除了空格以及结束标记,问题得到解决。