CodeIgniter Forums
The filetype you are attempting to upload is not allowed - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: The filetype you are attempting to upload is not allowed (/showthread.php?tid=10721)



The filetype you are attempting to upload is not allowed - El Forum - 08-10-2008

[eluser]PHP Programmer[/eluser]
Hi

I am getting an error while running file upload function. I am uploading the file format same as defined under 'allowed_types'/'mimetypes' ie gif,png,jpg.

Also, if I run it independently then it works fine but when I embed it in my code then the following error occurs.

The error says:

Array ( [error] =>

The filetype you are attempting to upload is not allowed
)

My Code is: (Under 'controller' directory)

$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->load->library('upload', $config);

if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());

print_r($error);
}
else
{
$data = array('upload_data' => $this->upload->data());

echo "success";
}