My codeigniter app suddenly broke today. I didn\'t work on the upload code and when I tried to upload an image today I suddenly got \"The filetype you are attempting to upload i
I've had this problem twice, here are the two solutions that have worked for me;
1 - The mime type reported by the system can vary, and may not be in the array of mime types set for a particular file extension. .csv files are the worst I have found for this. Find out what mime type the system is reporting by dumping the upload data after your upload
die($this->upload->data());
The 'file_type' index will contain a string - add this to the array value with the index that matches the desired file extension in application/config/mimes.php
2 - The most recent time I have had this is when I upgraded my core Codeiginter version from 2.x to 3.x. I updated the contents of the system directory, but not application/config. I didn't spot the fact that the application/config/mimes.php file is slightly different - the newer version returns an array whereas the old one included it as a var. The fix was to copy in the newer version of mimes.php
Have you initialize the $config
properly?
$this->load->library('upload', $config);
$this->upload->initialize($config); // Make sure it has been initialized
Not sure if this helps, I had this problem only on my Windows Dev Machine running on a test server on local host, on my live web hosting it worked fine detecting mime types.
I had a quick look at the upload library itself, and I found that you can just stick a * in the allowed types to allow anything.
Don't think this was documented anywhere in the manual, but sorted the problem for me as I just wanted to get my script up and running locally to do some work on it.
Initialize $config
and remove base_url()
from upload path. It will work properly.
$this->upload->initialize($config);
I had the same problem today.
What I did is just to copy the whole content of CodeIgniter-3.0.6\application\config\mimes.php
to my application\config\mimes.php
.