i have same problem. other files doc, xls uploads fine. but pdf uploading gives error. “The filetype you are attempting to upload is not allowed.”
in config/mimnes.php i have:
'pdf' => array('application/pdf', 'application/x-download', 'application/download'),
in controllers i have:
function upload_file($type, $upload_type)
{
$this->load->library('upload');
//upload file
switch($upload_type){
case "image":
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|jpg|png|pdf';
$config['max_size'] = '3000';
$config['max_width'] = '3224';
$config['max_height'] = '1268';
break;
case "doc":
$config['upload_path'] = './uploads/pages/doc/';
$config['allowed_types'] = 'pdf|doc|docx|xls|ppt';
$config['max_size'] = '3000';
$config['encrypt_name'] = TRUE;
break;
}
foreach($_FILES as $key => $value)
{
if( ! empty($value['name']))
{
$this->upload->initialize($config);
if ( ! $this->upload->do_upload($key))
{
$errors = array('error' => $this->upload->display_errors());
$this->session->set_flashdata('flashError', $errors);
}
else
{
$this->page_model->process_file($type, $upload_type);
}
}
}
}
any help will be appreciable.
Remove this line:
Then add this line after end of switch block and before foreach block
You are loading the upload library and then setting config values, which has no effect.
Your modified function should look like this: