note 50068 deleted from features.file-upload by nlopess
| From: | nlopess@php.net | Date: | Fri, 25 Feb 2005 17:54:39 +0000 |
| Subject: | note 50068 deleted from features.file-upload by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-85541@lists.php.net to get a copy of this message | ||
Note Submitter: prowebdesign at frontiernet dot net
----
When using the super $_FILES, it's important to note when checking for the type of image file
using $_FILE['image'] ['type']; you define as many image types as you can. I
knew my code was flawless but it still wouldn't upload a simple JPEG image and later found
there are many types of JPEG definitions; not just 'image/jpeg'. But also
'image/pjpeg' Case in point, I was coded something to the effect of the following to allow
users to upload images to my site:
switch($_POST['image']; {
$filetype = $_FILES['image'] ['type'];
$mimestring = substr($filetype, 0, 10);
switch($mimestring) {
case 'image/jpeg':
include 'local/family/scripts/upload.php';
break;
case 'image/gif':
include 'local/family/scripts/upload.php';
break;
case 'image/png':
include 'local/family/scripts/upload.php';
default:
default:
die("File Must be of JPEG, GIF, PNG or BMP Image Type<br>
Please <a href='local/family/family_zone.ph p'>TRY AGAIN</a>");
}
}
?>
This should check for any and all jpeg images, right? Wrong! There are also image types of
'image/pjpeg', and PNG image types of 'image/x-png'...etc, etc.
Hope this helps!
PRO WEB Design