How to fix CodeIgniter not accepting RTF mimetype in Internet Explorer

While working with the CodeIgniter file upload library I discovered that I was able to upload RTF files in Chrome but not in Internet Explorer.

When executing:

$this->upload->do_upload()

I would get:

The filetype you are attempting to upload is not allowed

from:

$this->upload->display_errors()

After some research I found that this was due to the fact that sometimes different web browser describe a file with the same extension with a different mime type upon upload.

Luckily the fix is simple. Internet Explorer sets the mime type of an RTF to ‘application/msword’. All we need to do is add this mime type to our mimes.php config file. CodeIgniter accepts an array of mime types per file extension, so all we need to do to fix is open up application/config/mimes.php and replace the line:

'rtf' => 'text/rtf'

with:

rtf => array('text/rtf', 'application/msword')

You will now be able to upload RTF files in your CodeIgniter application via Internet Explorer. I hope that helps somebody!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>