I can upload files perfectly to uploads folder using Codeigniter on localhost. However when i try to upload on server i get this error. I have tried different types of files. txt, .doc .xls .jpg etc, which are all fine on localhost. i have looked in MIME file and image/jpeg is in for jpeg along with all the other file types i need (‘doc’ =>’application/msword’, etc etc….).
I have checked folder permissions also and they are ok, but it clear im not even getting that far due to the error.
Does anyone have any ideas why its not allowing me to upload my files.
string(57) "The filetype you are attempting to upload is not allowed." array(2)
{ ["testfile"]=> array(5)
{ ["name"]=> string(7) "123.jpg" ["type"]=> string(10) "image/jpeg"
["tmp_name"]=> string(14) "/tmp/phpVYtNNs" ["error"]=> int(0) ["size"]=> int(20921) }
["quotefile"]=> array(5)
{ ["name"]=> string(7) "123.jpg" ["type"]=> string(10) "image/jpeg"
["tmp_name"]=> string(14) "/tmp/phpIsvQ7x" ["error"]=> int(0) ["size"]=> int(20921) } }
Controller:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|txt|pdf|xls|csv|doc';
$config['max_size'] = '1000000';
$config['max_width'] = '100024';
$config['max_height'] = '76008';
$this->load->library('upload', $config);
Model:
if ( ! $this->upload->do_upload('testfile'))
{
var_dump($this->upload->display_errors('', ''));
var_dump($_FILES);
//$error = array('error' => $this->upload->display_errors());
//echo '<pre>'; print_r($error); echo '</pre>';
//$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data('testfile'));
$this->load->view('upload_success', $data);
}
$upload_data = $this->upload->data('testfile');
if ( ! $this->upload->do_upload('quotefile'))
{
$error = array('error' => $this->upload->display_errors());
echo '<pre>'; print_r($error); echo '</pre>';
//$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data('quotefile'));
$this->load->view('upload_success', $data);
}
If you are using version 2.1.0, there is a bug in the upload library. Refer the below link, it is explained clearly here.
Uploading in Codeigniter – The filetype you are attempting to upload is not allowed