Why excel is not being uploaded throught codeigniter?

386 views Asked by At

Hi, I want to upload excel file and after upload, I would like to insert (file-path) parse file and insert data into database and an error occures in my controller no matter what mimetype I set it to accept unless wildcard is applied.

error

(The filetype you are attempting to upload is not allowed.)

I used some code mentioned in below-

$this->_require_admin();
$this->load->library('spreadsheet_excel_reader');
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');

$file_element_name = "excelFile";

$configUpload['upload_path'] = 'insexcel/';
$configUpload['allowed_types'] = 'XLS|text/comma-separated-values|application/csv|application/excel|application/vnd.ms-excel|application/vnd.msexcel|text/anytext|text/plain|text/csv|csv|application/vnd.ms-excel';
$configUpload['max_size'] = '5000';
$configUpload['encrypt_name'] = TRUE;
$this->load->library('upload', $configUpload);

if (!$this->upload->do_upload($file_element_name)) {
    $status = 'error';
    echo $msg = $this->upload->display_errors('', '');
} else {
    echo "not upload";
}

And if i assign $configUpload['allowed_types'] = '*'; then file is being uploaded successfully. I want check a proper mime type of file.

How to insert excel data into database?

How to upload excel file into server and parse it?

0

There are 0 answers