View previous topic :: View next topic |
Author |
Message |
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
Posted: Fri Apr 18, 2008 10:17 pm Post subject: image/jpeg detection issues |
|
|
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 |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Fri Apr 18, 2008 10:44 pm Post subject: |
|
|
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 |
|
|
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
Posted: Fri Apr 18, 2008 10:53 pm Post subject: |
|
|
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 |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Fri Apr 18, 2008 10:58 pm Post subject: |
|
|
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 |
|
|
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Fri Apr 18, 2008 11:01 pm Post subject: |
|
|
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 |
|
|
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
|
Back to top |
|
|
|