Welcome Guest, Not a member yet? Register   Sign In
How i can upload File in CI
#1

[eluser]An Phu[/eluser]
I'm using upload file library in CI to upload xls files but i can't use it . when i execute upload site it always say :"The filetype you are attempting to upload is not allowed."

This my code :
Code:
function do_upload()
    {
    $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'xls';
        $config['max_size']    = '4096';
        
      
        $this->load->library('upload', $config);
    
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            
            $this->load->view('upload_form', $error);
        }    
        else
        {
            $data = array('upload_data' => $this->upload->data());
            
            $this->load->view('upload_success', $data);
        }
    }

and this is my define in mine file :
Code:
'xls'    =>    array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
#2

[eluser]An Phu[/eluser]
Please show me how i can upload excel file from upload library of CI , i'm trying step by step guide of CodeIgniter Guide but it not work. Does it have any sequence in file type allow ?
#3

[eluser]LuckyFella73[/eluser]
In an other thread I read that you need to define allowed
filetypes as following if the excel file is made with Excel 2007:
Code:
$config['allowed_types'] = 'xls|xlsx'; // xlsx is needed for excel 2007
#4

[eluser]An Phu[/eluser]
I'm just using excel 2003 , and i found my problem at my firefox .My upload site ok when i using safari and ie7.
Thanks for reply
#5

[eluser]metamorpher[/eluser]
I had the same problem... Why firefox cannot upload XLS?????
#6

[eluser]An Phu[/eluser]
I don't know but when i update my firefox to version 3.5.2 ,remove all addon and only install firebug 1.4.2 so it work >.<
#7

[eluser]pistolPete[/eluser]
What mime type does the browser send?
Add it to the $mimes array in mimes.php.
#8

[eluser]LuckyFella73[/eluser]
[quote author="metamorpher" date="1251786982"]I had the same problem... Why firefox cannot upload XLS?????[/quote]

It is not that firefox can't upload xls. The problem is (sometimes) that different
browsers handle mime types of files in a different way.
#9

[eluser]An Phu[/eluser]
So how to correct it ?
#10

[eluser]pistolPete[/eluser]
[quote author="An Phu" date="1251812339"]So how to correct it ?[/quote]

Find out which mime type the browser sends, then add this mime type to the $mimes array:
Code:
$mimes = array( ...
                'xls'    =>    array('application/excel', 'application/vnd.ms-excel', 'add-your-type-here'),
...




Theme © iAndrew 2016 - Forum software by © MyBB