CI_Upload.php bug? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CI_Upload.php bug? (/showthread.php?tid=31915) |
CI_Upload.php bug? - El Forum - 07-06-2010 [eluser]mrbinky3000[/eluser] Okay, I think I've found a genuine bug with the native upload class, or at least an undocumented feature. First, some info about the version of CI_Upload.php... Code: /** In a nutshell: you can't seem to combine image types and non-image types in the same array of allowed file types. I will use the source code from the official File Upload Class documentation page as the base code for this test. Follow the tutorial on that page to create the controller and two views. Now, in the upload.php controller, append "doc" to the existing list of allowed file types around line 19. like so... Code: function do_upload() Now, try and upload a Microsoft Word document. It fails saying the following. Quote:"The filetype you are attempting to upload is not allowed." Yes, it is allowed. I specifically added it to the list! Re-edit $config['allowed_types'] and remove everything but 'doc'. Go ahead and ammend some other non-image types. Then try it again. IT WORKS! The problem lies in the native uploading class. There is an "if" statement that is triggered if ANY image file types are listed in the $config['allowed_types'] Read the comments in my code for the details. Code: /** A couple of things. The text for that error message needs to change to "Can't get image size for non-image file" or something less misleading. Second, WHY test my doc file as an image file in the first place. Why is that foreach loop even there. It should be a switch / case instead or an if statement Psuedo code below... Code: if (in_array($my_file_type, $image_file_types)) CI_Upload.php bug? - El Forum - 07-06-2010 [eluser]Hernando[/eluser] It's a bug in CodeIgniter 1.7.2. It's ok in CodeIgniter 2.0 In Upload.php change: if (in_array($val, $image_types)) by if ($this->file_ext == '.'.$val && in_array($val, $image_types)) Cheers, Hernando CI_Upload.php bug? - El Forum - 11-02-2010 [eluser]BaRzO[/eluser] I am havin problem with upload lib maybe this is a bug i don’t know… I run Ubuntu 9.10 and Firefox I created an empty file with gedit and I renamed it to test.gif my upload conf is jpg||png|gif when I try to upload this file I get errors because of getimagesize trying to get its size… you can check this to : http://ellislab.com/forums/viewthread/146338/ |