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; } Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.