因为我无法获得所需的 pecl_http 扩展,所以我需要更改这段代码
<?php
$files = array(
array(
'name' => 'torrent', // Don't change
'type' => 'application/x-bittorrent',
'file' => 'my.torrent' // Full path for file to upload
)
);
$http_resp = http_post_fields( 'http://torcache.net/autoupload.php', array(), $files );
$tmp = explode( "\r\n", $http_resp );
$infoHash = substr( $tmp[count( $tmp ) - 1], 0, 40 );
unset( $tmp, $http_resp, $files );
?>
改为使用 curl,这是我到目前为止所拥有的;
<?php
$files = array(
array(
'name' => 'torrent', // Don't change
'type' => 'application/x-bittorrent',
'file' => '0-273-70244-0.pdf.torrent' // Full path for file to upload
)
);
$ch = curl_init(); //this part we set up curl
curl_setopt($ch, CURLOPT_URL,'http://torcache.net/autoupload.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $files);
$xml_response = curl_exec($ch);
curl_close($ch);
return $xml_response;
$infoHash= substr($xml_response,0,40);
但是出现了问题,因为上传后没有显示字符串,我只是得到一个空白网页
有任何想法吗?