Welcome Guest, Not a member yet? Register   Sign In
File upload mime-type problems we meet again
#1

[eluser]predi[/eluser]
Im using 2.1.3
I've got a problem uploading various files, for example "xls" ones using the "upload" library.

Here's my "xls" definition in the mimes.php:
Code:
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel')

Here's the code:
Code:
$this->load->library('upload', $config);
  
if(!$this->upload->do_upload('file'))
{
   print_r($_FILES);
   print_r($this->upload->data());
   die();
}

And here's the output that i get:
Code:
// $_FILES tells us its a "application/vnd.ms-excel" and it's defined in the "xls" mimes
// WTF? Y U NO UPLOAD then ?!
[file] => Array
        (
            [name] => test.xls
            [type] => application/vnd.ms-excel
            [tmp_name] => D:\wamp\tmp\phpC972.tmp
            [error] => 0
            [size] => 27136
        )
)
Code:
// the $_FILES global tells us "application/vnd.ms-excel"
// CI recognizes as "application/msword"
// O_o
Array
(
    [file_name] => test.xls
    [file_type] => application/msword
    [file_path] => D:/wamp/www/upload/
    [full_path] => D:/wamp/www/test.xls
    [raw_name] => test
    [orig_name] =>
    [client_name] => test.xls
    [file_ext] => .xls
    [file_size] => 27136
    [is_image] =>
    [image_width] =>
    [image_height] =>
    [image_type] =>
    [image_size_str] =>
)

And here's the .htaccess just in case
Code:
AddType application/excel xls xlsx

So... Why is the upload library recognizing mimes wrong?!
Thx in advance, been struggling few hours so far...
#2

[eluser]goFrendiAsgard[/eluser]
I'm not quite sure, but it seems there is a problem with upload library.
Maybe this thread can help you http://ellislab.com/forums/viewthread/70998/
#3

[eluser]predi[/eluser]
Me either. Its seems like its a OS (win7) problem. As CI uses system utils for mime recognition.
As a temp solution i just added "application/msword" to "xls" mimes.
Works, but still investigating...
thx for yr reply btw
#4

[eluser]InsiteFX[/eluser]
Detailed information for file extension XLS:

--------------------------------------------------------------------------------

Primary association: Excel

Company: Microsoft Corporation

File classification: Spreadsheet

Mime type: application/vnd.ms-excel [official], application/msexcel, application/x-msexcel, application/x-ms-excel, application/vnd.ms-excel, application/x-excel, application/x-dos_ms_excel, application/xls
Identifying characters Hex: D0 CF 11 E0 A1 B1 1A E1 00 , ASCII:
Program ID: Excel.Sheet.5 , Excel.Sheet.8 , soffice6.xls

Related links: Free Microsoft Viewer, OpenOffice.org, Zoho Viewer (Web Viewer)




Theme © iAndrew 2016 - Forum software by © MyBB