Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function curlToFile($url, $filename, $download_folder) {
- if (!(file_exists($download_folder)))
- mkdir($download_folder);
- chdir($download_folder);
- $fp = fopen($filename, "w+");
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_POST, 1);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
- curl_setopt($curl, CURLOPT_REFERER, "http://www.somedomain.com");
- curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.10) Gecko/20100504 Firefox/3.5.10");
- curl_setopt($curl, CURLOPT_FILE, $fp);
- $ret = curl_exec($curl);
- if (!$ret) {
- $this->lastError = curl_error($curl);
- }
- curl_close($curl);
- return $ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement