php - why my file_put_contents call create a zero byte image? -


i trying create site use amazon api display book information. however, images downloaded showing 0 byte. code running on virtual serever, curl enabled.

for example, image: http://ecx.images-amazon.com/images/i/51d1zp4f80l.sl75.jpg

my code this:

try {     $ch = curl_init($coverimageurl);     $imgname = "images/".$isbn.".png"; //assume png     $imgfullpath = $_server['document_root']."/".$imgname;     curl_setopt($ch, curlopt_header, 0);     curl_setopt($ch, curlopt_returntransfer, true);     $fb = curl_exec($ch);     if($fb === false) {         echo 'something wrong';         }      curl_close($ch);     file_put_contents( $imgfullpath, $fb );     }     catch (exception $e) {     echo 'caught exception: ',  $e->getmessage(), "\n";     die("problem image"); } 


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -