我有脚本从服务器下载种子文件:
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private");
header("Content-Description: File Transfer");
header("Content-Type: application/x-bittorrent");
header('Content-Length: '.filesize($local));
header("Content-Disposition: attachment; filename='"".$local."'"");
$file = fopen($local, "r");
print fread($file, filesize($local));
fclose($file);
如果我下载文件,种子坏了,无法使用,任何人都可以帮助我?错误是:
洪流文件解码失败!请尝试重新下载种子!
编辑:
$path = 'torrent/';
$local = $path.$row['file_src'];
我做很少的改变
header('Cache-control: private');
header('Content-Type: application/x-bittorrent');
header('Content-Length: '.filesize($local));
header('Content-Disposition: filename='.$download);
$file = fopen($local, "r");
print fread($file, filesize($local));
fclose($file);
编辑:抱歉,但总的来说,这没有问题,谢谢@deceze,问题出在种子文件中,下载后有一行下来。我该如何修复?
header("Content-Disposition: attachment; filename='"".$local."'"");
此行是一个问题,因为您的标题文本用 "
换行,但您的文件名子部分也用 "
换行,因此代码将无法理解使用相同的引号的两个层,因此请将其更改为:
header("Content-Disposition: attachment; filename='".$local."'");
这将维护标头的引号结构。