![]() |
File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php (/showthread.php?tid=8224) |
File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 05-09-2008 [eluser]Chris Newton[/eluser] Code: $config['allowed_types'] = 'png'; So, when I upload a 100x100px JPG, no errors are displayed, even though the file's of the wrong type, and sizes are incorrect. When I upload a 1011 kb file, the max_size error is reported.... so... why is one type error reported, and not the other? File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 05-09-2008 [eluser]Chris Newton[/eluser] It's not ignoring config. GD2 (or whatever that image library is) doesn't identify application/octet-stream as an image, and so is not gathering the width, height, etc, therefore silently failing. Now I'll have to figure out how to make GD2 recognize application/octet-stream as an image format..., or something. File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 05-09-2008 [eluser]Chris Newton[/eluser] The upload class uses a function called: is_image() to ascertain whether or not something is a PNG or JPG or GIF. That function contains its own mime descriptors, rather than using those set in mimes.php. In my case, I was using application/octet-stream (because swfupload sets that as the filetype for uploads) in the mimes.php file, which was getting ignored by the is_image function... therefore it wasn't returning any image data, because the upload class didn't think my file was an image. File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 05-09-2008 [eluser]Chris Newton[/eluser] Code: <?php if (!defined('BASEPATH')) exit('No direct access allowed.'); File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 05-09-2008 [eluser]Chris Newton[/eluser] Derek Jones considers the current implementation correct for security purposes: quote: "Validating an image based on application/octet-stream is rather dangerous. is_image() uses its own qualifiers based on real-world needs of browsers and security for uploading images. I would recommend in your case that you extend the Upload class and replace is_image() with your own method if you wish to be more liberal with what you accept as being a valid image." If you plan to use SWFUPLOAD and want to attempt to validate width, height, etc of the uploaded file, you'll need to use the upload extension above to use mime types set in mimes.php, or hardcode your own mimetypes to suit. File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 06-03-2008 [eluser]kallus[/eluser] I wrote some code that uses fileinfo to give files with mime type application/octet-stream a more specific mime type, maybe someone finds it useful. http://ellislab.com/forums/viewthread/81308/ File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 06-16-2008 [eluser]hybriid[/eluser] just in case anyone else is stuck with the error "path does not appear to be valid"...look here http://ellislab.com/forums/viewthread/80481/ File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 06-16-2008 [eluser]mglinski[/eluser] Same problem with me like 4 months ago. Fixed the issue in 10 mins, just override the is_image function and insert your own. -Matt File Upload Class ignoring config [solved] -CI Upload class function is_image() ignores mimes.php - El Forum - 06-17-2008 [eluser]Chris Newton[/eluser] Right... which is what I did. Above. |