Upload filetype not allowed?? - 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: Upload filetype not allowed?? (/showthread.php?tid=27614) |
Upload filetype not allowed?? - El Forum - 02-17-2010 [eluser]rogierb[/eluser] Yeah, it looks okay, but is doesnt work... So either $this->mimes_types is off or some other random error. Can you debug is_allowed_filetype()? See why it is returning a FALSE? Upload filetype not allowed?? - El Forum - 02-17-2010 [eluser]123wesweat[/eluser] hmmm, in Upload.php in function is_allowed_filetype() i added Code: foreach ($this->allowed_types as $val) and when i upload a jpg it returns Code: doc when i try to upload a .txt Code: doc Now the strange thing is when i use Code: $config['allowed_types'] = 'txt|text'; Is there a particular order we should follow?? Upload filetype not allowed?? - El Forum - 02-17-2010 [eluser]123wesweat[/eluser] Ok this is strange this seems to be a working array Code: $config['allowed_types'] = 'doc|docx|pdf|txt|text|rtf|jpg|gif'; not working Code: $config['allowed_types'] = 'doc|docx|gif|jpeg|pdf|jpg|rtf|txt|text'; Upload filetype not allowed?? - El Forum - 02-17-2010 [eluser]rogierb[/eluser] The order shouldn't matter. Can you debug set_allowed_types() to see what $types and $this->allowed_types are? Upload filetype not allowed?? - El Forum - 02-17-2010 [eluser]Craig300[/eluser] I had a similar problem and found that if I put the pdf file extension at the beginning of that list, it seemed to work. Eg: pdf|doc|docx etc Upload filetype not allowed?? - El Forum - 02-20-2010 [eluser]Vangelis B[/eluser] [quote author="rogierb" date="1266418911"]The order shouldn't matter. Can you debug set_allowed_types() to see what $types and $this->allowed_types are?[/quote] Unfortunately the people are right. The order does matter. The reason is that the upload library first does a check for images before check in the config/mimes.php. The library checks to see if the temp file (during the upload) returns an image size. Unfortunately it does the check for files that are not images as well. Obviously this is a bug. A temporary solution is to comment the following lines in system/libraries/upload.php Code: if (in_array($val, $image_types)){ they are around line 565 I'll submit this bug and lets hope that CI devs will come up with a fix in the next CI version. Upload filetype not allowed?? - El Forum - 02-22-2010 [eluser]crojac[/eluser] See my post on the subject http://ellislab.com/forums/viewthread/146338/ Upload filetype not allowed?? - El Forum - 04-23-2010 [eluser]Phil Sturgeon[/eluser] This has been fixed in CodeIgniter 2.0. Upload filetype not allowed?? - El Forum - 06-29-2010 [eluser]Unknown[/eluser] As far as RTF goes, this can be a tricky mime-type to deal with. In general, the mime-type for RTF is 'application/rtf' and NOT 'text/rtf' (according to w3schools and good ol' M$). So right off the hop, Codeigniter has a possibly incorrect mime-type listed. HOWEVER, some products stamp the mime-type as 'application/msword' for RTF files. We had to change the 'rtf' entry in the mimetypes array (located in /system/application/config/mimes.php) to be 'application/msword' to get our users' RTF files uploading correctly. This may have something to do with the way the RTF file type is defined on their Windows XP computers, I am not 100% certain. WHEN IN DOUBT, install the Live HTTP Headers Add-On in Firefox, it will let you know what the browser is thinking in terms of what the file type is that is being uploaded. Upload filetype not allowed?? - El Forum - 07-14-2010 [eluser]Ossama Khayat[/eluser] I suffered trying to fix this, and after some debugging I found the solution, which is what in the patch for 2.0. Why isn't this also fixed for 1.7.2? |