Загрузка изображения с внешнего URL с помощью cURL - PullRequest
1 голос
/ 29 ноября 2010

Как загрузить внешнее изображение с URL с помощью cURL?

Ответы [ 2 ]

1 голос
/ 29 ноября 2010

Смотрите здесь:

http://www.edmondscommerce.co.uk/php/php-save-images-using-curl/

function save_image($img,$fullpath){
 $ch = curl_init ($img);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
 $rawdata=curl_exec($ch);
 curl_close ($ch);
 if(file_exists($fullpath)){
  unlink($fullpath);
 }
 $fp = fopen($fullpath,'x');
 fwrite($fp, $rawdata);
 fclose($fp);
}

Другие статьи / источники:

http://forums.digitalpoint.com/showthread.php?t=371632

http://www.bitrepository.com/download-image.html

http://php.bigresource.com/Track/php-Jjg3DsKY/

0 голосов
/ 29 ноября 2010

с php.net - также читает в строку.

   <?php
        // create curl resource
        $ch = curl_init();

        // set url
        curl_setopt($ch, CURLOPT_URL, "example.com");

        //return the transfer as a string
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // $output contains the output string
        $output = curl_exec($ch);

        // close curl resource to free up system resources
        curl_close($ch);     
?>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...