Search code examples
phpcodeigniterframeworksuploading

Codeigniter issue with uploading (v2.1) - (Wrong filetype)


The following function keeps telling me that I have uploaded the wrong filetype even though I am definately uploading a PDF file - can anyone suggest what is going wrong?

// output of the var_dump's
$this->upload->data() (array)
file_name   brochure.pdf
file_type   [empty string]
file_path   D:/Shared/Web Sites/site-dev/documents/
full_path   D:/Shared/Web Sites/site-dev/documents/brochure.pdf
raw_name    brochure
orig_name   [empty string]
client_name brochure.pdf
file_ext    .pdf
file_size   369498
is_image    FALSE
image_width [empty string]
image_height    [empty string]
image_type  [empty string]
image_size_str  [empty string]

$data (array)
error   

The filetype you are attempting to upload is not allowed.

function do_upload()
{
    $config['upload_path'] = './documents/';
    $config['allowed_types'] = 'pdf|doc';

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

    if ( ! $this->upload->do_upload('File'))
    {
        $data = array('error' => $this->upload->display_errors());
                    var_dump($this->upload->data());
                    var_dump($data);exit;
        //$this->load->view('upload_form', $error);
    }
    else
    {
        $data = array('upload_data' => $this->upload->data());

        //$this->load->view('upload_success', $data);
    }

    return $data;
} 

Solution

  • Fixed - problem with 2.1 (see my post above)