The following code uses curl to simulate the POST request link directly after displaying the contents of the file, how to modify to not display the content and directly download the request to the. torrent format file?
function Curl_post ($header, $data, $url) {$ch = Curl_init (); $res = curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_ssl_verifyhost, FALSE); curl_setopt ($ch, Curlopt_ssl_verifypeer, FALSE); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_postfields, $data); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_httpheader, $header); $result = curl_exec ($ch); Curl_close ($ch); if ($result = = NULL) { return 0;} return $result;} $url = ' http://www.bttiantang.com/download4.php '; $header = Array ("Host:www.bttiantang.com", "content-type:application/x-www-form-urlencoded", ' user-agent : mozilla/4.0 (compatible; MSIE. 0; Windows NT 6.1; trident/4.0; SLCC2;); $data = ' action=download&id=26881&uhash=eecf3d3071a7b672c314bc39 '; $ret = Curl_post ($header, $data, $url);// You need to change the content display to file download echo $ret;
Reply to discussion (solution)
Do not echo $ret;
Write the $ret to the file. Save it.
Do not echo $ret;
Write the $ret to the file. Save it.
Tried it.
Header ("Content-type:application/force-download");
$ret;
The download is the PHP blank file
Use
$filename = $ret;
Header ("Content-type:application/force-download");
Header ("content-disposition:attachment; Filename= ". basename ($filename));
ReadFile ($filename);
Then download a bunch of garbled PHP files
The downloaded filename itself is defined as the suffix of the. Torrent This seed is 5.FLIGHTS.UP.2014.LIMITED.720P.BRRIP.XVID.AC3-RARBG?
$ret = Curl_post ($header, $data, $url);//need to change the content display to file download $filename = ' x.torrent '; header ("content-type:application/ Force-download "); header (" Content-disposition:attachment; Filename= $filename "); Echo $ret;
Download the x.torrent with Thunderbolt open for
$ret = Curl_post ($header, $data, $url);//need to change the content display to file download $filename = ' x.torrent '; header ("content-type:application/ Force-download "); header (" Content-disposition:attachment; Filename= $filename "); Echo $ret;
Download the x.torrent with Thunderbolt open for
Thank you very much for the technical support provided by Xuzuning and Bingovictor, and I have previously used a file to obtain the requested content and then use the B file to download a file and customize the naming and suffix.
The methods provided by moderators are more efficient and more convenient. Thank you.