Welcome Guest, Not a member yet? Register   Sign In
File upload class issue
#1

[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?
#2

[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 ?
#3

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

[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?
#5

[eluser]Andrewkha[/eluser]
Here you go
#6

[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!!!
#7

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

[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.
#9

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




Theme © iAndrew 2016 - Forum software by © MyBB