[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);
}
}
}
?>
Now here is my upload_form
Code:
<html>
<head>
<title>Upload Form</title>
</head>
<body>
<?php echo $error;?>
<?php echo form_open_multipart('upload/do_upload');?>
<input type="file" name="userfile" size="40" />
<br /><br />
<input type="submit" value="upload" />
</form>
</body>
</html>
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