Skip to main content
Known Participant
September 21, 2012
Question

cffile MIME types

  • September 21, 2012
  • 5 replies
  • 11499 views

One of my users was trying to upload a Microsoft Word document using CFFILE.  The document was created in  Office 2007, but was saved in Office 2003 format (.doc).  The upload is done  with this code, which has worked in the past with PDF's:

<cftry>

    <cffile action="UPLOAD"

        filefield="file_upload"

        destination="files\temp"

        nameconflict="OVERWRITE"

        accept="application/unknown,application/pdf,application/msword,text/html,text/plain,application/rtf,text/richtext,text/xml">

        <cfset accepted="true">

<cfcatch type="any">

    <cfset accepted="false">

</cfcatch>   

</cftry>

When I cfdump the cfcatch structure after this fails, it shows the MIME type of the file that I was attempting to upload as "application/x-tika-msoffice"

When I add this MIME type to the accept parameter of cffile and try the upload again, it gives this error:

The MIME type or the Extension of the uploaded file application/x-tika-msoffice was not accepted by the server.

What can I do to allow this file to be uploaded?

I am using CF10 Standard on IIS 7.5 on Windows Server 2008R2.

Thanks.


This topic has been closed for replies.

5 replies

Inspiring
June 13, 2013

try by giving the new attribute (strict = "false") for cffile. This is the new attribute introduced in CF 10.

cherdt
Inspiring
June 13, 2013

Thanks Adbul, that will be useful for CF10 users!

I noticed that the strict attribute is not listed in the ColdFusion documentation, but that a good description of its use is provided on CFFILE Restricting file types to upload.

Inspiring
December 18, 2012

Just saw this and experienced the same problem.  This has nothing to do with IIS.  I found out if you have OpenOffice installed you can only use the OO acceptable MIME types application/x-tika-msoffice or application/x-tika-ooxml .

Not sure if this is intended to be a feature or a bug, but I had to uninstall OO for my purposes, so I consider it a bug.

Inspiring
December 18, 2012

I'd say definitely a bug. Even if it's "by design", it's just daft. Have you filed a bug for it?

--

Adam

Inspiring
December 18, 2012

Actually, doing it now.

Update: Bug 3431165

Inspiring
September 26, 2012

It's the wrong mime type. For .docx it's:

   application/vnd.openxmlfor

mats-officedocument.wordprocessingml.document

http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/05/08/office-2007-open-xml-mime-types.aspx

Known Participant
September 26, 2012

I was uploading a .doc, not a .docx, and my .doc file was giving the MIME type of application/x-tika-msoffice.

Inspiring
September 24, 2012

Is the error coming from CF or IIS?  It's IIS that needs to "accept" the upload.  You might have to do some jiggery-pokery (can you tell I am no IIS expert? ;-) on it to allow that MIME type to be accepted.  It might not be a CF problem.

--

Adam

Inspiring
September 24, 2012

Sorry, was responding to your first post, having not seen the follow-up one.

Hmmm.  Seems unlikely it's IIS that's blocking it if changes to the <cffile> call changes the behaviour.

Sorry for the bum steer on my previous post.  So I'm back to being "void of ideas" now.

I'll have a look @ it though to see if I can replicate.

--

Adam

Known Participant
September 24, 2012

IIS has a list of a bazillion MIME types, but "application/x-tika-msoffice" is not included in the list.  I tried to add it for the ".doc" extension, but it said that there was already a MIME type for that extension, the one that "should" be used: "application/msword".

Since I got it to work, I have moved on to bigger and better things.

Thanks.

Known Participant
September 21, 2012

I wanted to mention that when I remove the accept parameter, it allows the file no problem.  Would still be nice to know why it wasn't working though, or why the Word file was sending the wrong MIME type.