CodeIgniter Forums
Mime Type errors for upload library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Mime Type errors for upload library (/showthread.php?tid=1100)



Mime Type errors for upload library - bmarker - 02-11-2015

I'm getting an error stating that the "type is not allowed", but I've tried both the file extension and the mime types separated by pipes.  

I'm attempting to allow uploads of .odt, .ods, .odp, .docx, .xls, txt, zip, and  .pdf files.

Code:
$config['allowed_types'] = 'application/vnd.oasis.opendocument.spreadsheet | application/vnd.oasis.opendocument.text | application/vnd.oasis.opendocument.presentation | application/vnd.openxmlformats-officedocument.wordprocessingml.document | application/vnd.ms-excel | application/vnd.openxmlformats-officedocument.presentationml.presentation | zip | txt | application/pdf';

Here is where I got the MIME types for the LibreOffice files.

Any ideas?


RE: Mime Type errors for upload library - CroNiX - 02-11-2015

Did you try not using spaces between the pipe separated types? (type1|type2|type3) vs (type1 | type2 | type3)


RE: Mime Type errors for upload library - bmarker - 02-12-2015

Nope doesn't work, I actually tried the spaces second. Could it be a server issue?

I've added the MIME types to config->mimes.php, still doesn't work...


RE: Mime Type errors for upload library - bmarker - 02-12-2015

Not happy with the solution, but I used.
$config['allowed_types'] = '*';
to allow all


RE: Mime Type errors for upload library - CroNiX - 02-12-2015

For troubleshooting, I'd try a single mimetype at a time. Upload a file with that mimetype and if it works, add the next one separated by a pipe and retry the upload with that new filetype. Keep going until it breaks.

I've never tried to put mimetypes directly in the $config['allowed_types'] and have always used a piped delimeter of extensions (pdf|jpg|gif), with the corresponding mimetypes in the /config/mimes.php config file. According to the docs, you should be able to use the mimetypes directly in the $config['allowed_types'], but I've never tried.