Tôi muốn tải xuống tệp có Curl. Vấn đề là liên kết tải xuống không được trực tiếp, ví dụ:Tải xuống tệp Curl với url var
http://localhost/download.php?id=13456
Khi tôi cố gắng để tải về các tập tin với curl, nó tải file download.php!
Đây là mã curl của tôi:
###
function DownloadTorrent($a) {
$save_to = $this->torrentfolder; // Set torrent folder for download
$filename = str_replace('.torrent', '.stf', basename($a));
$fp = fopen ($this->torrentfolder.strtolower($filename), 'w+');//This is the file where we save the information
$ch = curl_init($a);//Here is the file we are downloading
curl_setopt($ch, CURLOPT_ENCODING, "gzip"); // Important
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_URL, $fp);
curl_setopt($ch, CURLOPT_HEADER,0); // None header
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); // Binary trasfer 1
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
Có cách nào để tải các tập tin mà không biết con đường?