Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Invalid Mimetype Detection for .xls file with CF10

Guest
Oct 26, 2012 Oct 26, 2012

After upgrading to CF10, we are having issues getting our server to properly recognize any mimetype associated with the .xls file extension.  For some odd reason, the server is viewing them as a word file type and rejecting it.   

When we upload a file with the .xls extension, the server responds back with the following error message:

"The MIME type or the Extension of the uploaded file application/msword was not accepted by the server. Only files of type application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet can be uploaded. Verify that you are uploading a file of the appropriate type. The error type is Application."

Our only workaround for the time being is uploading all files in the newer .xlsx format, which the server properly accepts.  As you will see from the above error message, those are the mimetypes I have thus far.  The other work around is updating the tika jar files which I have included more details in my bug report link below, but that is a solution we are steering off of until we get further confirmation on the solution. 

I've reported this possible bug to Adobe, but of course it will be weeks or months before a confirmation or response is made on it since there are countless other bugs / feature requests that are still unanswered.  So I'm reaching out to the community in efforts to see if anyone else may have received the same issue or could see what we may be doing wrong. 

Link to bug report with more details: https://bugbase.adobe.com/index.cfm?event=bug&id=3343364

10.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 26, 2012 Oct 26, 2012

May seem like a stupid question, but: are you absolutely sure the file you are uploading is actually an Excel file and not a Word file that got renamed to .XLS?  The reason I ask is that with CF10, CF no longer just looks at file extensions to determine MIME type - it sniffs the file headers to determine type.

-Carl V.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 26, 2012 Oct 26, 2012

Yes, when a user reported the issue that is the first thing I did to test and replicate the issue. 

First Replication Process:

Open Microsoft Excel --> Enter any data --> Save as Excel 97-2003 Workbook (*.xls)

Upload --> Invalid Mimetype Detection Error Returned

We have a catch to detect a blank file as well, it does not even get to that point.  🙂

Second Replication Process:

Open Microsoft Excel --> Enter no data (blank file) --> save as Excel 97-2003 Workbook (*.xls)

Upload --> Invalid Mimetype Detection Error Returned

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 26, 2012 Oct 26, 2012

OK.  Just wanted to eliminate that.  Hopefully someone else will chime in.

-Carl V.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 26, 2012 Oct 26, 2012

As an extra step to troubleshoot, in case CF might work in tandem with the web server, can you check on the webserver to ensure that the .xls extension has its mime type set properly?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 26, 2012 Oct 26, 2012

In our case we are under a Windows Server environment with IIS 7.5.  To answer your question - yes, I've already verified the xls extensions are properly set in the IIS mime types section.  If there is a different area that I can check, please do let me know. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 26, 2012 Oct 26, 2012

If you guys want to replicate this in your local environment, it's very easy using the steps I outlined in my bug report.  Please report back on your results.  I would love to see if other users experience the same or different.

Steps to Reproduce:

1. Create cfset tags to specify what type of files and mime types are allowed for user uploads.

<cfset uploadFileFilter = ".xls,.xlsx" />

<cfset uploadFileMimeType = "application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

2. Define where the file will be uploaded to using the cffile attribute. (Change destination to the same directory of where you are creating the current .cfm file below)

<cffile action = "upload"

fileField = "fileupload"

destination = "C:\test\"

accept = "#uploadFileMimeType#"

nameConflict = "MakeUnique">

3. Finally create a simple form that allows the user to upload files.

<cfform enctype="multipart/form-data">

<cfinput accept="#uploadFileMimeType#" type="file" name="FileContents">

<br/>

<cfinput type="submit" name="submit" value="Upload File">

</cfform>

4. Open excel, enter any data, and save it as an .xls file.

5. Submit it to the form.

Final code

<cfset uploadFileFilter = ".xls,.xlsx" />

<cfset uploadFileMimeType = "application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

<cfif isDefined("Form.FileContents") >

    <cffile action = "upload" 

        fileField = "FileContents" 

        destination = "C:\EnterLocalPathHere\" 

        accept = "#uploadFileMimeType#" 

        nameConflict = "MakeUnique">

<cfelse>

    <cfform enctype="multipart/form-data">

        <cfinput accept="#uploadFileMimeType#" type="file" name="FileContents">

        <br/>

        <cfinput type="submit" name="submit" value="Upload File"> 

    </cfform>

</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2012 Oct 27, 2012

I could reproduce the bug on CF 10, and have voted in the bugbase.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 16, 2013 Apr 16, 2013

 

Adobe validated my bug report about a month and half ago then with an update to the bug report status as 'ToFix.'  However, I can no longer access the bug report anymore.  I'd like to know why it was removed.  My understanding was that regardless of the bug being invalid, fixed, etc it would be reported and updated as such on the status.  I am logged in and have tried looking by manually typing in bug id # 3343364, but nothing comes up.  Original Link: https://bugbase.adobe.com/index.cfm?event=bug&id=3343364


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 25, 2013 Apr 25, 2013

Anyone here to answer this?  Was my bug just completely deleted even after it was validated?  Please advise.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2013 Jun 24, 2013

I have the latest update 10 and I am seeing this issue as well.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 25, 2019 Jun 25, 2019
LATEST

I know I'm late to the party, but in case it can help someone else...

Zadi I just tried your final code and there is a mistake:

Final code

<cfset uploadFileFilter = ".xls,.xlsx" />

<cfset uploadFileMimeType = "application/excel,application/vnd.ms-excel,application/x-excel,application/x-msexcel,app lication/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

<cfif isDefined("Form.FileContents") >

    <cffile action = "upload"

        fileField = "FileContents"

        destination = "C:\EnterLocalPathHere\"

        accept = "#uploadFileMimeType#"

        nameConflict = "MakeUnique">

<cfelse>

    <cfform enctype="multipart/form-data">

        <cfinput accept="#uploadFileFilter#" type="file" name="FileContents">

        <br/>

        <cfinput type="submit" name="submit" value="Upload File">

    </cfform>

</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 13, 2012 Dec 13, 2012

Would appreciate if we can get an answer on this issue from an official Adobe rep! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Dec 13, 2012 Dec 13, 2012

What does FileGetMimeType(myfile) return for the .xls file ?

I got the following:

"application/vnd.ms-excel" for 1997-2003 xls file

"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" for the .xlsx file

Let us know.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 14, 2012 Dec 14, 2012

It returned application/msword for .xls file. 

MIMETYPE.PNG

I have detailed as much info on the bug here and have other users who have also replicated this same issue.

https://bugbase.adobe.com/index.cfm?event=bug&id=3343364

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 02, 2013 Jan 02, 2013

Hello, any updates on this issue?  I feel there are quite a few users who have reported this issue already to my bug report; would appreciate any attention towards a patch update or resolution to address this.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 17, 2013 Jan 17, 2013

I wanted to see if any of your developers or yourself were able to verify this issue.  I've listed as much detail as possible in replicating it on CF10 in the bug post.  https://bugbase.adobe.com/index.cfm?event=bug&id=3343364

But received no responses from your team as of yet.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 18, 2013 Jan 18, 2013

As a possible work around until, the CF team fixes this issue you could use magicmime from riaforge.

http://magicmime.riaforge.org/

Similar to how Linux/Unix check the contents of a file to determine their type, instead of using the file extension, this CF function performs a similar task.

Simple CFFUNCTION that returns a structure detailing the filetype/mimetype etc.

Currently supports:-

Adobe PDF Document

Microsoft Office Open XML Format Document

Microsoft Office Open XML Format Spreadsheet

Microsoft Office Open XML Format Presentation

Microsoft Office Word 97-2003 Document

Microsoft Office Excel 97-2003 Document

Microsoft Office Powerpoint 97-2003 Document

Graphics interchange format Image

Portable Network Graphics Image

JPEG Image

HTML (Experimental)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 26, 2013 Jul 26, 2013

In attempting to tighten our uploads, we also have run into this problem. I was able to work around the problem thanks to this writeup. I made sure that I accepted both excel and msword if the type of file being uploaded was excel. Then after the call to this function, I needed to manually change the file type to excel before continuing the upload.

It works ok, but the bug really should be investigated and fixed. I have no idea what happened to your bug report, but it is no longer accessible.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 26, 2013 Jul 26, 2013

This error should no longer be occuring, at least it does not for us. I'm guessing Adobe fixed it or it is from one of the more recent Java updates.

You might be able to fix it on your end by updating to the most recent version of CF or updating to the following java versions, which we have installed on our production server:

Java 7 Update 25 (64-bit)

Java SE Development Kit 7 Update 17 (64-bit)

Java SE Development Kit 7 Update 25 (64-bit)

Java 6 Update 39 (64-bit)

Java SE Development Kit 6 Update 38 (64-bit)

Java SE Development Kit 6 Update 39 (64-bit)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 29, 2013 Jul 29, 2013

Thank you for this information. We updated our development server this

morning and the problem was corrected. Now all we have to do is figure out

when we can update the production servers in order to get the correction!

Glenda

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 31, 2013 Jul 31, 2013

We put this on our production servers, then a couple days later, the problem reappeared. We've gone back to providing a work-around for when we want to restrict the uploads to Excel spreadsheets. Before the cffile a check is made to see if we are restricting the file type to only be Excel, then adding msword as a MIME type to check for.

Since we also have a call to FileGetMimeType, we need to override the value returned if it is returning MSWord and it should have been Excel.

Are there any ideas as to why the fix worked for a brief time, then stopped working? The servers still had the latest ColdFusion and Java.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 14, 2014 Nov 14, 2014

Did you ever get this fixed - I've just come across the same issue.

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources