I’m trying to create a custom file upload (using CI’s upload class) but when uploading a CSV file the file type is being set as “text/html” and therefore fails the mime type checks. All other file types I’ve tested are uploaded correctly. I even have XSS filtering set to Off.
Any ideas what’s going on here?
EE 2.2.1
Hello David,
I am sorry to hear you are running into this snag.
Can you check your system/expressionengine/config/mimes.php file for the CSV file type? If it is not yet defined, adding it there should help. If it is in there, make sure that for some reason it was not set incorrectly.
Please let me know if this helps.
Cheers,
Hi Shane
Yes, it’s there. Here’s what I’ve got:
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),Looks good to me. What else can I try?
Hi David,
From the looks of it, it seems your developing an add-on?
Can you give me a little more insight into what your goal is? Where is the provided file field type falling short for you?
If you can explain to me what your desired end result is, I’m happy to offer suggestions. However, if you are needing help with add-on development, I’ll have to move this into Development and Programming.
I look forward to your reply!
Cheers,
Hi Dan
Yes, it’s a custom module and one of the methods is to import a CSV file into a custom db table using CI’s Upload class. However on uploading the .csv file, with the ‘allowed_types’ parameter set to “csv|xls|xlsx”, the $_FILES[‘type’] global var has the type set as ‘text/html’, therefore fails the file type test.
I realise this sounds like it could be a browser issue but the upload function used to work just fine on the same site a few months back before I upgraded EE from 2.1.4 to 2.2.1
With allowed_types set as “*” the upload works fine. So maybe it’s a CodeIgniter issue.
Okay, so ye, please nudge this over to whichever forum you deem appropriate.
Cheers
David
Hi David,
One quick question here, are you using the upload class as through the EE super object or at the model level where it’s is directly called by CI?
I’ll get this over to Development and Programming. The Community there is far more versed in these issues that we are!
Cheers,
Hi, I have the same problem, debugging CI code find two possible solutions
1 - add the mime type to the file mimes.php as is mentioned before 2 - in the upload class in method do_upload at line 207 ci call the private method is_allowed_filetype(), that’s make the method set by default ignore_mime as FALSE, if you call the method like is_allowed_filetype(TRUE) this solve the problem because methon don’t do any check of mime type. But… as you can see you have to modify CI code because there is not way by parameter to change how you call the method.
Perhaps in the future someone correct this problem. sorry for may bad english. 😉
I successfully fixed that error, thank you. Edit by grow a garden a day ago
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.