Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
OK. Just wanted to eliminate that. Hopefully someone else will chime in.
-Carl V.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
I could reproduce the bug on CF 10, and have voted in the bugbase.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Anyone here to answer this? Was my bug just completely deleted even after it was validated? Please advise.
Copy link to clipboard
Copied
I have the latest update 10 and I am seeing this issue as well.
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
Would appreciate if we can get an answer on this issue from an official Adobe rep!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It returned application/msword for .xls file.
I have detailed as much info on the bug here and have other users who have also replicated this same issue.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Did you ever get this fixed - I've just come across the same issue.
Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now