I'm writing a custom php application that should allow downloading of torrent files. 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:
Unable to load - Torrent is not valid 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. I removed the whitespace along with the closing tag and the problem was fixed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.