Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Since I got it to work, I have moved on to bigger and better things.
Fair enough. I wasn't too sure if your solution of removing the MIME type was something to considered a solution, or just an observation. Wanna mark that comment of yours as the answer?
--
Adam
Copy link to clipboard
Copied
I don't really consider it an answer, since the original problem wasn't solved, but worked around.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I was uploading a .doc, not a .docx, and my .doc file was giving the MIME type of application/x-tika-msoffice.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I'd say definitely a bug. Even if it's "by design", it's just daft. Have you filed a bug for it?
--
Adam
Copy link to clipboard
Copied
Actually, doing it now.
Update: Bug 3431165
Copy link to clipboard
Copied
Stephen, just to clarify, you're saying that Open Office was installed on the ColdFusion server (not the client system)?
I was seeing the same issue, and allowing application/x-tika-msoffice and application/x-tika-ooxml appears to have addressed the issue, although Open Office wasn't installed on either the client or server.
CF10 includes Tika 0.6 (cfusion\lib\tika-core-0.6.jar and cfusion\lib\tika-parsers-0.6.jar), which presumably have something to do with the issue. I'm just not sure how uninstalling Open Office would have fixed it in your scenario.
Copy link to clipboard
Copied
Correct, when OO was installed, I could not define the correct MIME type for new and legacy office formats (e.g. doc or docx) and they would not upload using cffile. Once it was uninstalled I could define the correct type and the behavior was as expected.
Copy link to clipboard
Copied
I actually reported an issue very similiar to this a few months back, my bug report went as far as being 'verified' by Adobe Developers then magically 'disappeared' without any notice. I had several people from these forums including some of the well known CF Devs put in a vote for it. Here is the original thread - http://forums.adobe.com/thread/1088884 and the bug report link that is currently in nowhere land - https://bugbase.adobe.com/index.cfm?event=bug&id=3343364.
Copy link to clipboard
Copied
try by giving the new attribute (strict = "false") for cffile. This is the new attribute introduced in CF 10.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now