image/jpeg detection issues

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Fri Apr 18, 2008 10:17 pm    Post subject: image/jpeg detection issues Reply with quote

Hello Everybody,

On my YouN00b site I have it set up where members can upload images to the site (similar code is used for avatars too).

Everything seems to work fine, with the exception of JPEG images. For some reason, the PHP doesn't see to be detecting that it exists.

Here's the code to detect the MIME type of it:

Code:
if (($_FILES["file"]["type"] == "image/gif") or ($_FILES["file"]["type"] == "image/jpeg") or ($_FILES["file"]["type"] == "image/png"))
{
//Process Upload code here, not really needed.
}
else
{
echo "<strong>Invalid Upload.</strong><br /> Image Submissions must be in GIF, JPG, or PNG format.";
die;
}



(Please, no jokes about my horrible error handling :P)


Anyway, I've yet to experience issues with it, but SEVERAL of my members are.

The upload page consists of just a file upload input box, and submit button.

I'm running PHP 5.24 (preconfigured package from Aprelium), and it didn't work on 5.16 either.

Abyss X2 v2.5


---

My members browsers range from IE6 to IE7, FireFox (multiple versions), Opera, and Safari, and all or most seem to be causing this error.

It seems as if I can upload an image that another member cannot, and it's not like I gave myself any sort of special override for it.

[edit]MIME Type from the Abyss Control Panel:
image/jpeg jpeg jpg jpe[/edit]

Thanks for any help in advance!
_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Fri Apr 18, 2008 10:44 pm    Post subject: Reply with quote

Its to do with the way the browsers handle the mimetypes. The JPEG one is fussy and needs a different mimetype for IE browsers. I don't remember what it is but a google search should find it quickly enough.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Fri Apr 18, 2008 10:53 pm    Post subject: Reply with quote

I'm looking now, if I find a solution for this before I leave for work, I'll let everybody know what I find.

Thanks.

EDIT:
Edit wrote:


Now that I looked for a few minutes, it appears as if this post might answer it:
AbyssUnderground wrote:
The browser. pjpeg is for IE, and jpeg is for FF. Its a stupid thing but I had to correct it on my script to check for both.


From way back in 2004

I'll check it out and see how it works. Thanks AbyssUnderground.

_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Fri Apr 18, 2008 10:58 pm    Post subject: Reply with quote

Quote:
//Open the image using the imagecreatefrom..() command based on the MIME type.
switch($mimetype) {
case "image/jpg":
case "image/jpeg":
case "image/pjpeg":
$i = imagecreatefromjpeg($temporary_name);
break;
case "image/gif":
$i = imagecreatefromgif($temporary_name);
break;
case "image/png":
case "image/x-png":
$i = imagecreatefrompng($temporary_name);
break;
}


pjpeg <-- thats the mimetype you need.


EDIT: Beat me to it from an old post quote :-)
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Fri Apr 18, 2008 11:00 pm    Post subject: Reply with quote

Thanks again...It's a pretty annoying bug, and I couldn't figure it out.

Much appreciated!
_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Fri Apr 18, 2008 11:01 pm    Post subject: Reply with quote

Toasty wrote:
Thanks again...It's a pretty annoying bug, and I couldn't figure it out.

Much appreciated!


No problem. Take a look at the PNG mimetype as well, that has an extra one.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Fri Apr 18, 2008 11:08 pm    Post subject: Reply with quote

Will do...

I'm sure I'll find another one of your posts :P
_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group