File upload allowed file types - 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: File upload allowed file types (/showthread.php?tid=16450) |
File upload allowed file types - El Forum - 03-06-2009 [eluser]danny123[/eluser] Not sure if this is a bug as it's easily circumvented by the way you define the allowed file types for the file upload class. When the file is being validated in CI_Upload::is_allowed_filetype(), it first checks for image types in the array of allowed types. The problem comes in your pipped string of allowed types that you define. If you define some like "jpg|gif|png|zip|txt" and you try to upload a zip file, you'll get an error that the allowed type is not defined, even though it has been defined. The reason this is happening is that the is_allowed_filetype() method iterates through your pipped string, and since it first checks for a valid image, a zip file is clearly not an image. The simple work around is to just to define all of your non-image files first, then place your image types at the end. The revised definition would look like "zip|txt|jpg|gif|png". -daniel File upload allowed file types - El Forum - 03-06-2009 [eluser]pistolPete[/eluser] Has been reported already: http://codeigniter.com/bug_tracker/bug/6780/ File upload allowed file types - El Forum - 03-06-2009 [eluser]danny123[/eluser] Ah, thanks. File upload allowed file types - El Forum - 03-09-2009 [eluser]Unknown[/eluser] Please check its already reported File upload allowed file types - El Forum - 04-05-2009 [eluser]Zelaza[/eluser] Yes, thanks very much..... was trying to figure it out |