简体   繁体   中英

Download a torrent file through PHP

I'm creating a torrent platform (without tracker) and I have some problems while downloading the torrent from the server.

This is my part of the script:

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

When I download the torrent throught this file (download.php in my case), torrent is not valid bencoding. What's the problem or what I have to do?

I think this might work...can't able to test as torrent links are banned in my country :-(

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

PHP 不能下载torrent,您可能需要安装Transmission并使用Transmission api来使用PHP管理和下载torrent。

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.

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