note 50068 added to features.file-upload
| From: | prowebdesignatfrontiernetdotnet at osu1 dot php dot net | Date: | Thu, 17 Feb 2005 06:00:43 +0000 |
| Subject: | note 50068 added to features.file-upload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85147@lists.php.net to get a copy of this message | ||
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
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50068
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50068&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50068&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50068&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50068&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50068&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50068&report=yes
Search -- http://master.php.net/manage/user-notes.php