Page 1 of 2
Image Question
Posted: Fri Feb 17, 2006 5:55 pm
by icesolid
I have a script that determines a file type and then it thumbnails the photo depending on the image type. Now all of my code is correct and works because on another server I use the exact same code and it works fine.
I get this error when using the exif_imagetype() function on this server:
Fatal error: Call to undefined function: exif_imagetype() in /home/caposcom/public_html/test.php on line 2
I tested to see if exif_imagetype() was the was the function causing the error above by using this code in a test file that nothing else in it but this code:
Code: Select all
<?php
if (exif_imagetype('/home/caposcom/public_html/photos/aerial.jpg') != IMAGETYPE_GIF) {
echo 'The picture is not a gif';
}
?>
Does this host need to adjust something in their server? The host is peoplehost.com, thus far I am not satisfied this is my second problem with them.
Posted: Fri Feb 17, 2006 6:03 pm
by nickman013
The picture path does not have to be from the root. It has to be /path/to/file or
http://www.site.com/path/to/file.jpg
I Know
Posted: Fri Feb 17, 2006 6:09 pm
by icesolid
I understand that, however using photos/file.jpg or
http://www.capo-us.com/photos/file.jpg or the root directory still gives me that error.
Anyone?
Posted: Fri Feb 17, 2006 6:10 pm
by feyd
it would appear that you don't have the exif extension installed.. which is pretty often on hosts.
Really?
Posted: Fri Feb 17, 2006 6:16 pm
by icesolid
HHM... thats weird, they should have it installed right?!??!
Anyways is there any other way to determine weither a image is .GIF or .JPG, thats all i need to determine.
Posted: Fri Feb 17, 2006 6:30 pm
by Benjamin
Can't you use the file extension or do you have to read the image to check it?
Posted: Fri Feb 17, 2006 6:31 pm
by feyd
getimagesize(), which is a built-in function.
Huh?
Posted: Fri Feb 17, 2006 6:34 pm
by icesolid
How does getimagesize() give me the image type?
Posted: Fri Feb 17, 2006 7:45 pm
by John Cartwright
clearly sais how in
the manual 
Posted: Fri Feb 17, 2006 9:44 pm
by s.dot
if you just need to check extensions and you're not worried about malicious file uploads
Code: Select all
$file_ext = strtolower(strstr($_FILES['fieldname']['name'],"."));
that will return the exstension .gif .jpg .jpeg .tif etc
Posted: Fri Feb 17, 2006 10:15 pm
by josh
@scrotaye,
that's so not secure
Posted: Sat Feb 18, 2006 2:39 am
by s.dot
scrotaye wrote:if you just need to check extensions and you're not worried about malicious file uploads
depends on the purpose. if it's an admin section and he's going to be the only one uploading, then it wouldn't be a problem
Posted: Sat Feb 18, 2006 5:45 am
by onion2k
scrotaye wrote:if you just need to check extensions and you're not worried about malicious file uploads
Code: Select all
$file_ext = strtolower(strstr($_FILES['fieldname']['name'],"."));
that will return the exstension .gif .jpg .jpeg .tif etc
The $_FILES array also gives you the MIME type .. easier than mucking about with the name. Though you need to remember FF and IE report different MIME types for certain images.
Posted: Sat Feb 18, 2006 8:58 am
by feyd
...and you need to understand the inherant security issues with relying on that information. Which is VERY easy to fake.
Question
Posted: Sat Feb 18, 2006 10:36 am
by icesolid
onion2k wrote:scrotaye wrote:if you just need to check extensions and you're not worried about malicious file uploads
Code: Select all
$file_ext = strtolower(strstr($_FILES['fieldname']['name'],"."));
that will return the exstension .gif .jpg .jpeg .tif etc
The $_FILES array also gives you the MIME type .. easier than mucking about with the name. Though you need to remember FF and IE report different MIME types for certain images.
Does FF and IE report different MIME types for JPEG or GIF? because those are the only file types I am allowing to be uploaded.
The only file types allowed to be uploaded are JPEG or GIF so thats all I check for, if the file is not JPEG or GIF I send an error message saying NOT PROPER FILE TYPE.
And how do I use $_FILES[""] to pull out the MIME types?