Answer the question
In order to leave comments, you need to log in
Why can't I upload an XLSX file in Codeigniter 3 to a LAMP server?
Good time, colleagues!
The essence of the problem is this: when uploading xlsx files via the Upload standard library in CI version 3.0.6, an error "The filetype you are attempting to upload is not allowed" is written to the log. In $config['allowed_types'] the xlsx format is enabled. Google says it's MIME types. In the file /application/config/mimes.php - the type is specified like this:
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel ', 'application/msword', 'application/x-zip'),
When uploading a file, the type "Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" is indicated in the header.
Tried adding the type to .htaccess - the same parsley.
And xls and csv files are loaded without problems. Also on WAMP builds like Denwer and OpenServer everything is fine.
In this case, the host is on Ubuntu 16.04
Tell me which way to dig?
Answer the question
In order to leave comments, you need to log in
$this->load->helper(array('text'));
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'xls|xlsx|xlsm';
$config['file_name'] = convert_accented_characters($_FILES['excel_file']['name']);
$this->load->library('upload', $config);
$is_uploaded = $this->upload->do_upload('excel_file');
<?php echo form_open_multipart('/reader/update') ?>
<input type="file" name="excel_file">
<?php echo form_close() ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question