Welcome Always
Welcome Always

Reputation: 367

CodeIgniter can't upload pdf but other are working fine only pdf can't

this is the controller

public function create()
{
    if (!$this -> correct_permission('author')) {
        redirect(base_url() . 'user_admin/login');
    }
$this->load->helper('form');
$this->load->library('form_validation');
$config['upload_path'] = './uploads/search/';
$config['allowed_types'] = 'pdf|doc|xml|pdf';
$this->load->library('upload', $config);
$data['title'] = 'Create a news item';

$this->form_validation->set_rules('title', 'Title', 'required');

//ADMIN CHECK

if (! $this->upload->do_upload() && $this->form_validation->run() === FALSE)
{

$this->load->view('admin/header');
$this->load->view('admin/document/create');
$this->load->view('admin/footer');
}
else
{

$this->document_m->set_document();
$image_data = array('upload_data' => $this->upload->data());
$this->load->view('admin/document/create');
}   
}

here i can upload the doc files but only the PDF doesn't upload Wat's the problem.. here i can upload the doc files but only the PDF doesn't upload Wat's the problem.. here i can upload the doc files but only the PDF doesn't upload Wat's the problem..

Upvotes: 1

Views: 4147

Answers (1)

Kees Sonnema
Kees Sonnema

Reputation: 5784

For debugging just use the following first:

$config['allowed_types'] = '*';

See if you get an error uploading. if not, you have to delete the second 'pdf' form your code it is mentioned 2 times.


Remove this line from your mimes.php in 'application/config/mimes.php'

'pdf'    =>    array('application/pdf', 'application/x-download'), 

And replace with this:

'pdf'    =>    array('application/pdf', 'application/x-download', 'application/unknown'), 

This should fix your problem!

Upvotes: 2

Related Questions