Загрузка изображений на imageshost по курлу

Загружает по курлу указанный урл (грузит с веба, не с локального компа), возвращает ссылку на картинку.

function UploadImage($iurl){
 echo date("r")." fetching $url\r\n";
 echo date("r")." sending $postvars\r\n";
 $ch = curl_init();
 $postvars = "type=3&qnt=1&isurl=1&userimg1=$iurl&to_size_w=&to_size_h=&to_angle=0&pvs1=350&quality=100&pr_text=Увеличить&text=description=rules=on&submit_button=Загрузить";
curl_setopt($ch, CURLOPT_POST      ,1);
curl_setopt($ch, CURLOPT_POSTFIELDS    , $postvars);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1);
curl_setopt($ch, CURLOPT_HEADER      ,1);
curl_setopt($ch, CURLOPT_TIMEOUT,15);
//    curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_COOKIEJAR, "c1.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "c1.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "http://imageshost.ru/upload.php");
curl_setopt($ch, CURLOPT_USERAGENT, "Firefox/3.0");
$result = curl_exec($ch);
curl_close($ch);
preg_match("!img=(.*?)\]!i", $result, $out);
$result = $out[0];
return $result;
}
0.00 avg. rating (0% score) - 0 votes

3 комментария

  • хм… интересный код
    интересное решение, обязательно найду применение) спасибо

  • Такое точно в хозяйстве сгодится, хочу как раз фотосайт сделать себе. Спасибо.

  • Выдает ошибку  Error: Sorry, but we’ve detected that unexpected data is received. Required parameter ‘fileupload’ is missing or your post is not multipart/form-data. Как можно исправить?

css.php