Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:51:26+00:00 2026-06-17T06:51:26+00:00

I am using getimagesize() to collect image information loaded remotely. The problem is if

  • 0

I am using getimagesize() to collect image information loaded remotely.

The problem is if the remote server takes too long on the request or the image doesn’t exist and I get an error timeout. What can I do to prevent this, so that if it takes 15 seconds to load automatically make the request then return some code returning null $width, $height, and $type?

if($siteImage != "None"){
list($width, $height, $type) = getimagesize($siteImage);
if(!filter_var($siteImage, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)){
    die("fillDiv('checkImage','<font color=\"red\">Image is not valid URL type.</font>');");
}elseif($width != "468" || $height != "60"){
    die("fillDiv('checkImage','<font color=\"red\">Incorrect size.</font>');");
}elseif($type != "1" && $type != "2" && $type != "3"){
    die("fillDiv('checkImage','<font color=\"red\">Incorrect image type. (.jpg .gif .png) only</font>');");
}else{
    print("fillDiv('checkImage','');");
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:51:27+00:00Added an answer on June 17, 2026 at 6:51 am

    You have two options.

    1 Use getimagesize but in two lines, and hide error messages. Check for a return value

    $aSize = @getimagesize($url);
    if ($aSize) {
        // You have a return values
        list($width, $height, $type) = $aSize;
    } else {
        // No return values
        $width = 0;  // etc
    }
    

    2 User cUrl to copy the file locally. You can control the timeous better with curl, also you can check if the file exists or is taking too long to download etc. Once copied locally, use getimagesize() on the local file. It will only then fail if the file is not a genuine image. Quick online example: http://www.weberdev.com/get_example.php3?ExampleID=4009

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you download, resize and store an image from a remote server using
I am using getimagesize in PHP to get information about an image in my
Problem Using PHP to download a remote image using the same URL before and
I'm using imagecache_create_path() and getimagesize() to get the path of a imagecache-generated image and
I've been using getimagesize() to get the dimensions of an image a user is
I am using PHPs GD extension for jpg image manipulation. I am using getimagesize()
I'm using Uploadify to upload an image to the server. The image is uploaded,
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
Using SQL Server 2008 R2 we are looking for a way to select the
Using Microsoft SQL Server 2005, is there any way to see when a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.