Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem with MIME-type while uploading a file to server from the web-interface. I used CI as engine for my website. I have FreeBSD with Apache 2.2.15 on the board.
The problem is:

  1. While i upload doc-file, i get application/x-msword, ppt - application/, xls - application/ - this is normal.
  2. But when i try to upload docx, pptx, xlsx i get application/octet-stream; rar - application/force-download - and this is wrong.

UPD1. In my mime.types file these MIME-types are present with required type (ie. application/openxmlformats-officedocument.wordprocessingml.document)
UPD2. I wrote "AddType app.../openxml... .docx" in httpd.conf directly and restart apache, but nothing happened.
UPD3. Upload form has enctype "multipart/form-mixed"
UPD4. Content-type in Firebug`s NET-panel have a wrong MIME-type also

share|improve this question
I've no idea what 'CI' is. Are you sure its not storing the mimetype that the file was uploaded with? Did you edit /etc/mime.types or the mime types config file for Apache (they may not be the same)? – symcbean Jul 26 '10 at 16:26
CI means "CodeIgniter" - PHP framework. I edit apache22/mime.types config file. – kirillorloff Jul 26 '10 at 16:37
Your question is so unclear. What do you actually mean when you say "i get application/x-msword"? How do you get it? Why should apache httpd care what type of file you upload? – Max Kosyakov Jul 28 '10 at 5:27
I use Firebugs function fb()` to get info about $_FILES. There is the variable type in this array - that is how i get MIME-type "application/x-msword". So, who should care? AFAIK, while uploading, my files are passing through Apache first. Why he has table of mime-types (mime.types)? – kirillorloff Jul 28 '10 at 16:36
It looks like you just did not read the manual! – Max Kosyakov Aug 20 '10 at 5:28

This is because .docx files are actually ZIP files with a different extension. If you open one of them up in WinRAR or WinZIP you'll find dozens of .xml files inside them. My guess is that FreeBSD is not aware of the difference between a .docx and a .zip file, because they're the same thing.

That said, I'm really not sure what you're asking or what you're trying to achieve.

share|improve this answer
In system mime.types FreeBSD knows difference between .docx & .zip. My aim is right recognizing MIME-types by Apache (or PHP - load as mod_php). Nor force-download, neither octet-stream for MIME-types that has "apache22/mime.types". – kirillorloff Jul 28 '10 at 16:43

I don't know about the CodeIgniter Framework, but I do know that I have seen a couple PHP based applications that have this problem. If you fire up wireshark and sniff the HTTP taffic you may see that the computer that uploads the file is setting the wrong MIME type. If your PHP application blindly assumes that the uploader knows the correct type there may not be much you can do.

share|improve this answer
Yeah, when i sniff HTTP-headers, i see wrong Content-type sendind to server (UPD4). That is a question - what should i do to get right Content-type OR right MIME-type? How i can "teach" default PHP uploader to recognize right type? – kirillorloff Jul 28 '10 at 16:39
I haven't found a good solution yet... :| But I haven't really been working because it isn't that important of an issue on the system I saw it. A solution to the problem may have to be altering the PHP code and making a special exception for docx types. – Zoredache Jul 28 '10 at 16:52
I haven't found a good solution too! Maybe, you know how Apache and/or FreeBSD determines MIME-type? – kirillorloff Jul 28 '10 at 21:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.