CodeIgniter Forums
File upload class issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: File upload class issue (/thread-61027.html)



File upload class issue - El Forum - 09-01-2014

[eluser]Andrewkha[/eluser]
Hello!

I want to allow uploading both xls and xlsx files.
I have the following code in the controller:

Code:
$config['allowed_types'] = 'xls|xlsx';

and the following definitions in the mime config:

Code:
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel', 'application/vnd.ms-office', 'application/vnd.ms-excel.12'),
    'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-office', 'application/vnd.ms-excel.12'),

Uploading xls works well. But when I try to upload xlsx I get Wrong file type error.
What's wrong?


File upload class issue - El Forum - 09-01-2014

[eluser]Flemming[/eluser]
Everything looks fine, your definition in the mime config is similar to mine (although mine is shorter than yours):

Code:
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip'),

What happens if you temporarily change the allowed types in the controller to only allow xlsx:

Code:
$config['allowed_types'] = 'xlsx';

Will it now allow you to upload a .xlxs ?


File upload class issue - El Forum - 09-01-2014

[eluser]Andrewkha[/eluser]
No, it also doesn't work...


File upload class issue - El Forum - 09-01-2014

[eluser]Flemming[/eluser]
That's very strange... could you attach your xlsx file so I can try uploading it in my application, see if I get the same error?


File upload class issue - El Forum - 09-01-2014

[eluser]Andrewkha[/eluser]
Here you go


File upload class issue - El Forum - 09-01-2014

[eluser]Flemming[/eluser]
Uploaded successfully!

So... it's definitely a problem with your setup.

Running out of ideas (was hoping it wouldn't upload for me) - did you try this in your mimes config

Code:
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip'),

not that it should make any difference, just clutching at straws now!!!


File upload class issue - El Forum - 09-01-2014

[eluser]Andrewkha[/eluser]
Tried your config as well, but didn't help. OK, thanks for assistance, will try to find a bug...


File upload class issue - El Forum - 09-02-2014

[eluser]Andrewkha[/eluser]
I found a root cause. For some reason it determined the file type as 'application/vnd.ms-excel'. Once I added it into the xlsx mime definition, it works.


File upload class issue - El Forum - 09-02-2014

[eluser]Flemming[/eluser]
So pleased that you managed to solve it - good thinking to check what your server was determining the mime type as!