Problem with getimagesize

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Problem with getimagesize

Post by Benjamin »

This is returning false on valid images. I am using it to test whether an uploaded file is an image or not. What is the deal?

Code: Select all

if (!getimagesize($FILE)) {
    // not an image
  }
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you sure $FILE is set correctly?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Yeah I have a folder full of images, it works on about 1/10th of them. Images are all .jpg as well.

These are uploaded files by the way...

Code: Select all

$_FILES['ImageUpload']['tmp_name']
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Well I was using this..

Code: Select all

$Status = $_FILES['Image']['error'];
To test for an error with the file upload, but for some reason it wasn't throwing an error when the image wasn't uploaded due to the MAX_FILE_SIZE directive being set in the html document. Got it fixed now.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There are multiple types of jpeg files. Some are not encoded to the exact standard, they are considered errant by php. This is fixed in later versions of php if I remember the logs correctly however I can't find the bug right now detailing it.
Post Reply