From 2f35c4b91526d2d813601401a3e6563255f2b639 Mon Sep 17 00:00:00 2001 From: paulburdick Date: Sun, 24 Jun 2007 20:29:09 +0000 Subject: Modified the is_image() method in the Upload library to take into account Windows IE 6/7 eccentricities when dealing with MIMEs --- system/libraries/Upload.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'system/libraries/Upload.php') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 9d2bae2ae..fa1cf1e73 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -477,17 +477,28 @@ class CI_Upload { */ function is_image() { + // IE will sometimes return odd mime-types during upload, so here we just standardize all + // jpegs or pngs to the same file type. + + $png_mimes = array('image/x-png'); + $jpeg_mimes = array('image/jpg', 'image/jpe', 'image/jpeg', 'image/pjpeg'); + + if (in_array($this->file_type, $png_mimes)) + { + $this->file_type = 'image/png'; + } + + if (in_array($this->file_type, $jpeg_mimes)) + { + $this->file_type = 'image/jpeg'; + } + $img_mimes = array( 'image/gif', - 'image/jpg', - 'image/jpe', 'image/jpeg', - 'image/pjpeg', 'image/png', - 'image/x-png' ); - return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE; } -- cgit v1.2.3-24-g4f1b