Jump to content

Can I use curl_init() to grab an image file from another server?


igor berger

Recommended Posts

I use to use file_get_contents to get an image file from another server, but our hosting people have disabled the function.

Can I use curl_init() to get the image file from another server?

 

Will this work?

 

$url='http://www.somewebsite.com/image.gif';

vWritePageToFile( $url, $imgtfile );


function vWritePageToFile( $sHTMLpage, $imgfile ) {
     $sh =          curl_init( $sHTMLpage );
     $hFile =                      FOpen( $imgtfile, 'w' );
     curl_setopt( $sh, CURLOPT_FILE, $hFile );
     curl_setopt( $sh, CURLOPT_HEADER, 0 );
     curl_exec  ( $sh );
     curl_close(  $sh );
     FClose    (  $hFile );
   }

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.