简体   繁体   English

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

[英]Download .torrent file through php, Invalid Bencoding

I'm writing a custom php application that should allow downloading of torrent files. 我正在编写一个自定义php应用程序,该应用程序应允许下载torrent文件。 Files are located on the server, and per user request,I serve the file the following way: 文件位于服务器上,并且根据用户请求,我通过以下方式提供文件:

    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);
    }

But when I download and try to add the file to uTorrent I see the following error: 但是,当我下载并尝试将文件添加到uTorrent时,出现以下错误:

Unable to load - Torrent is not valid Bencoding. 无法加载-Torrent无效的Bencoding。

I searched around to find a solution to this exact problem without any success. 我四处搜寻以找到解决此确切问题的方法,但没有成功。

After nearly a day of searching and googling, i found the problem. 经过近一天的搜索和谷歌搜索,我发现了问题。 It appeared that there was a trailing whitespace after the closing php tag, inside one of the included php files. 似乎在关闭的php标记后,包含的php文件之一中有一个尾随空格。 I removed the whitespace along with the closing tag and the problem was fixed. 我删除了空白以及结束标记,并且此问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM