通过PHP下载torrent文件

时间:2015-10-03 19:55:45

标签: php

我正在创建一个torrent平台(没有跟踪器),从服务器下载torrent时遇到了一些问题。

这是我的脚本部分:

$fn = dirname(__FILE__) . "/torrents/$id.torrent";
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$tname.torrent");
header("Content-Length: ".filesize($fn));
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
readfile($fn);

当我通过这个文件下载torrent(在我的情况下是download.php)时,torrent不是有效的bencoding。 问题是什么或我必须做什么?

2 个答案:

答案 0 :(得分:0)

我认为这可能有效...无法测试,因为我的国家禁止使用torrent链接: - (

$file = "abc.torrent" 
$content = file_get_contents('http://www.example.com/sdfsdfs.torrent')
move_uploaded_file($content, '$file');

答案 1 :(得分:0)

PHP 无法下载种子,您​​可能需要安装transmission并使用transmission api来管理和下载种子PHP