Results 1 to 2 of 2

Thread: How to find if a remote image exists or can be displayed?

  1. #1
    Join Date
    Mar 2008

    Question How to find if a remote image exists or can be displayed?

    I've been using this function to check for broken images and it works for most of them but it says that some don't exist when they do display fine on my website.

    PHP Code:
    function remote_file_exists($url)
    $curl curl_init($url);
    //don't fetch the actual page, you only want to check the connection is ok
    //do request
    $result curl_exec($curl);
    $ret false;
    //if request did not fail
    if($result !== false)
    //if request was ok, check response code
    $statusCode curl_getinfo($curlCURLINFO_HTTP_CODE);  
            if (
    $statusCode == 200)
    $ret true;   

    For example this image shows up fine but I can't detect that it exists:


    also getimagesize() has the same problem, it can't get the size but the image displays fine.

    How can I find if an image will display in the browser without checking by hand?

  2. #2
    Join Date
    Nov 2008
    Works fine for me when I run it from my server using that image's URL (as does getimagesize()).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center