Welcome Guest, Not a member yet? Register   Sign In
Cannot upload an xls file
#1

[eluser]caperquy[/eluser]
Before asking that question I have been looking through the forum discussions but none of them gave me the answer.
This is my problem : I am trying to upload an excel file using the samples which are in the Codeigniter User Guide. I have just made few changes to adapt the code to xls files.
Whenever I try to load an excel file I get the following message :
Le type de fichier que vous tentez d'envoyer n'est pas autorisé. (i.e. The type of file you try to send is not authorized).

Following is my upload.php controler :

Code:
<?php

class Upload extends Controller {

    function Upload()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
    }

    function index()
    {
        $this->load->view('catalogue/upload_form', array('error' => ' ' ));
    }

    function do_upload()
    {
        echo "Passage dans do_upload <br />";
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png|xls';
        $config['max_size']    = '0';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';

        $this->load->library('upload', $config);
        print_r($this->upload->data());
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());

            $this->load->view('catalogue/upload_form', $error);
        }
        else
        {
            $data = array('upload_data' => $this->upload->data());

            $this->load->view('catalogue/upload_success', $data);
        }
    }
}
?&gt;

Now here is my upload_form

Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Upload Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php echo $error;?&gt;

&lt;?php echo form_open_multipart('upload/do_upload');?&gt;

&lt;input type="file" name="userfile" size="40" /&gt;

<br /><br />

&lt;input type="submit" value="upload" /&gt;

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;

The mimes.php file contains :

Code:
'xls'    =>    array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),

Could someone tell me what is wrong ?
Thanks in advance.

CapErquy




Theme © iAndrew 2016 - Forum software by © MyBB