Codeigniter download file doesn't work online but works on localhost
I want to ask about downloading codeigniter.
Codeigniter version 2.1.4
I can't upload the image to the folder online, but it works fine on localhost
.
My code for loading image
$config['upload_path'] = './assets/frontend/images/banner/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '0';
$config['max_width'] = '0';
$config['max_height'] = '0';
$this->upload->initialize($config);
$this->upload->do_upload('BannerImg');
$banimg = $this->upload->data();
$bantitle = $this->input->post('BannerTitle');
$bandesc = $this->input->post('BannerDesc');
$this->banner_model->addBanner($banimg,$bantitle,$bandesc);
Do you know what the problem is?
Try to find it but you can't find a solution.
Please if someone can help me.
Thank.
source to share
Since we found the issue in the comments, I'll just post it here as a link. upload_class
Most of the problem is with the codeigner, which seems to be bugged using some mime types. See similar problems:
-
CodeIgniter: "The type of file you are trying to upload is not allowed."
-
CodeIgniter "The type of file you are trying to download is not allowed." (not the same as 1.)
Quoting the accepted answer from point 1 above:
You are using Firefox, right?
You can try looking at system/libraries/Upload.php
line 199:
$this->_file_mime_type($_FILES[$field]);
Change this line to:
$this->_file_mime_type($_FILES[$field]); var_dump($this->file_type); die();
Then download the file .wmv
. It will show something like application/octet-stream
or something else. Add this to yours mimes.php
. Hope this help =)
Similar answer here
Note:
In your case, it probably won't be exactly the same, but the problem is similar and you have to find the appropriate file types as in the answer and add them to the file mimes.php
to solve this problem.
Some links:
source to share