maddogandnoriko Posted April 8, 2009 Share Posted April 8, 2009 I have a function that downloads an image via curl. If the image is not available the page is an html page stating the image is not available. How can I check to see if the url to download is an image or the html page? Thank you, maddogandnoriko function LoadImageCURL($save_to){ $ch = curl_init($this->source); $fp = fopen($save_to, "wb"); // set URL and other appropriate options $options = array(CURLOPT_FILE => $fp, CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 0, CURLOPT_TIMEOUT => 60); // 1 minute timeout (should be enough) curl_setopt_array($ch, $options); $result=curl_exec($ch); curl_close($ch); fclose($fp); return $result; } Link to comment https://forums.phpfreaks.com/topic/153203-solved-download-image/ Share on other sites More sharing options...
9three Posted April 8, 2009 Share Posted April 8, 2009 You can use the getimagesize() function to check if there is a size. If it returns false then there is no image. Link to comment https://forums.phpfreaks.com/topic/153203-solved-download-image/#findComment-804798 Share on other sites More sharing options...
maddogandnoriko Posted April 8, 2009 Author Share Posted April 8, 2009 Just What the doctor ordered! Thank you very much! Maddogandnoriko Link to comment https://forums.phpfreaks.com/topic/153203-solved-download-image/#findComment-805049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.