I tried, I looked and I almost died...but I couldnt find it.
I need to know if a file is jpg, but looking the extension isnt enough and I cant use the mime_content_type function because I have php 4.2 and this function is avaible until php 4.3.
Its not a email attachment or upload file, then the $_FILE (or the array where it contains the uploaded file...I forgot the name) doesnt work me.
Some ideas???
I will be glad you if you can help
thx everybody
Mime Type
Moderator: General Moderators
if your script is running on a unix-system you might use file with php's exec functions
-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
I think for separating jpegs from non-jepgs pootergeist's suggestion is better.
What exactly is the error you get?
to avoid a warning that might be printed (undefined index 2 in $a) try
What exactly is the error you get?
to avoid a warning that might be printed (undefined index 2 in $a) try
Code: Select all
<?php
$fileToCheck = 'notAJpeg.dat';
$a = @getimagesize($fileToCheck);
if (count($a) < 1 || $a[2] != 2)
echo 'not a jpeg';
else
echo 'all right';
?>