Загружает по курлу указанный урл (грузит с веба, не с локального компа), возвращает ссылку на картинку.
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;
}
3 responses
Do you want to comment?
Comments RSS and TrackBack Identifier URI ?
Trackbacks