trouble with file_mime_type() in upload.php |
This is the line of trouble: $mime = @finfo_file($finfo, $file['tmp_name']); The $mime says that it is a "text/plain;charset=utf-16le" but the screenshot attached shows that it is actually a "vnd.ms-excel". After this it is all downhill. A few lines down (line 1241 of upload.php) if (is_string($mime) && preg_match($regexp, $mime, $matches)) { $this->file_type = $matches[1]; return; } This causes the file_type to be text when I am only allowing XLS | XLSX. Any ideas on what to do?
proof that an old dog can learn new tricks
You can always add Mime Type to ./application/config/mimes.php
Code: Excel Mime Types: What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Thanks. As you can see, vnd.ms-excel already exists (first one) in mimes.php:
'xls' => array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
proof that an old dog can learn new tricks
I understand that, I was giving all of the other ones to try.
Sometimes the web gets them wrong and another type will work. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Perhaps I need to try some other way? I really don't want to hack up upload.php, that would be unmaintainable. Perhaps I could turn off the mimes checking?
How can I debug @finfo_file? Where can I find that code? Is that a built in php function? How about the character part? Do you know what that is? How about the "magic file"? What is that? Or is that the mimes.php we have talked about?
proof that an old dog can learn new tricks
php.net - finfo_file
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Found it, I think! Turns out that I had
extension=php_fileinfo.dll <<<<<<< I am using php5.6 and you don't need this dll in version of php after 5.3. I guess there was some kind of conflict going on between the built in finfo code and the finfo code in the dll Thanks for your help.
proof that an old dog can learn new tricks
Glad you figured it out.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |