Upload File Bug |
[eluser]Unknown[/eluser]
Hi adamp1, You are correct in your assumption. I reported this bug awhile back but there seems to be no fix. http://codeigniter.com/bug_tracker/bug/7291/ I have the fix completed in a hacked out Upload.php library class which I will post at the end of this post. The problem is 2 fold: Issue 1) The extra image check: If your file upload is an image then an extra image check will be performed. So in the code you will see the following: Code: if (in_array($val, $image_types)) The problem is that $val IS NOT YOUR UPLOADED FILE_EXTENSION. $val is defined a below: Code: foreach ($this->allowed_types as $val) So $val is an allowed type. What is an allowed type? An allowed type is a member of the list of files you are allowing users to upload. So basically if you are ALLOWING users to load images then an image check WILL ALWAYS OCCUR even if your user is uploading another filetype. The code below: Code: if (in_array($val, $image_types)) Code: if (in_array($ext, $image_types)) Issue 2) Random file types fail the filetype test: This problem occured when I realized that a PDF file I was trying to upload wasn't working. I kept getting the error message below: The filetype you are attempting to upload is not allowed. The problem was because the mime type for the TOTALLY LEGITIMATE PDF file was uploading was application/octet which can stand for any program really. Of course application/octet is not in the list of allowed PDF mime types - AND IT SHOULDN'T However we still have a problem and the problem is that the test for filetypes is TOO STRICT. My PDF file is legitimate and I can't help that its of mime type application/octet. My fix is to test to see if the file extension is allowed - if it is then let me through. Otherwise you will have situations where legitimate files are being rejected because they were set with a generic mime type. To fix for all your upload problems replace the function is_allowed_filetype in Upload.php with the code below. The hacked sections are enclosed in the comments: //kofic - hacking - start //kofic - hacking - end Code: /** |
Messages In This Thread |
Upload File Bug - by El Forum - 04-29-2009, 01:00 PM
Upload File Bug - by El Forum - 05-05-2009, 09:30 AM
Upload File Bug - by El Forum - 05-05-2009, 09:34 AM
Upload File Bug - by El Forum - 05-07-2009, 08:45 AM
Upload File Bug - by El Forum - 05-07-2009, 09:08 AM
Upload File Bug - by El Forum - 05-07-2009, 04:03 PM
Upload File Bug - by El Forum - 05-20-2009, 12:08 AM
Upload File Bug - by El Forum - 05-20-2009, 08:42 AM
Upload File Bug - by El Forum - 05-20-2009, 09:21 PM
Upload File Bug - by El Forum - 05-20-2009, 09:56 PM
Upload File Bug - by El Forum - 05-20-2009, 10:20 PM
Upload File Bug - by El Forum - 05-20-2009, 10:31 PM
Upload File Bug - by El Forum - 05-20-2009, 10:59 PM
Upload File Bug - by El Forum - 05-20-2009, 11:40 PM
Upload File Bug - by El Forum - 05-21-2009, 12:44 AM
Upload File Bug - by El Forum - 05-21-2009, 01:10 AM
Upload File Bug - by El Forum - 05-21-2009, 05:01 AM
Upload File Bug - by El Forum - 05-21-2009, 06:15 AM
Upload File Bug - by El Forum - 06-10-2009, 09:22 PM
Upload File Bug - by El Forum - 06-11-2009, 12:38 AM
Upload File Bug - by El Forum - 06-17-2009, 11:16 AM
Upload File Bug - by El Forum - 06-18-2009, 09:25 AM
Upload File Bug - by El Forum - 06-29-2009, 12:00 AM
Upload File Bug - by El Forum - 06-29-2009, 12:03 AM
Upload File Bug - by El Forum - 07-13-2009, 07:40 PM
Upload File Bug - by El Forum - 08-28-2009, 01:56 AM
Upload File Bug - by El Forum - 08-28-2009, 09:32 AM
Upload File Bug - by El Forum - 09-04-2009, 08:00 PM
Upload File Bug - by El Forum - 09-29-2009, 02:28 AM
Upload File Bug - by El Forum - 09-29-2009, 02:38 PM
Upload File Bug - by El Forum - 10-01-2009, 01:05 AM
Upload File Bug - by El Forum - 10-01-2009, 01:12 AM
Upload File Bug - by El Forum - 10-22-2009, 01:13 PM
Upload File Bug - by El Forum - 07-11-2011, 02:46 AM
|