Как-то так:
function curl_get_file($url, $path) {
$fp = fopen($path, 'w');
if ($ch = curl_init()) {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.16');
curl_setopt($ch, CURLOPT_COOKIE, 'sid=a96ff9ca21542826d88c8a20e26ea18z');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
curl_close($ch);
}
fclose($fp);
}
$name = ''; // Имя картинок (должно быть разное)
$url = 'http://'; //Адрес картинки
$path = 'files/' . $name . '.jpg'; // Куда сохраняем картинку
curl_get_file($url, $path);