0

I'm having problems uploading WMV and MPEG files, 'video/x-ms-wmv' (etc) are on the accept list - I get an error of

The MIME type or the Extension of the uploaded file application/octet-stream was not accepted by the server

Using Chrome, I check the header and it reads

Content-Disposition: form-data; name="fv_file"; filename="blahblah.wmv" Content-Type: video/x-ms-wmv

the Client machine also has the WMV registry entry which appears correct.

Server side Apache is configured to use the OS mime type file: /etc/mime.types. This file contains entries for wmv and mpeg: video/x-ms-wmv wmv video/mpeg mpeg

How does CF10 determine the mimetype? I'm struggling to find out this information. Does anyone have a solution?

Thanks

edit- Added Code

<cffile action="UPLOAD" filefield="fv_file" destination="#pathtotheserverroot##mediadir#/video/" nameconflict="MAKEUNIQUE"   accept="#qry_xxxx.OT_MIMETYPES#" mode="644">

The value of OT_MIMETYPES is

video/mp4,video/mpeg,video/quicktime,video/x-msvideo,video/x-sgi-movie,video/avi,video/vnd.vivo,application/vnd.rn-realmedia,video/vnd.rn-realvideo,audio/vnd.rn-realaudio,audio/x-pn-realaudio,video/x-ms-wmv,audio/mpeg,video/mpg,video/mpe,video/x-ms-asf,video/x-m4v

I did a CFDUMP for completeness

Accept   video/mp4,video/mpeg,video/quicktime,video/x-msvideo,video/x-sgi-movie,video/avi,video/vnd.vivo,application/vnd.rn-realmedia,video/vnd.rn-realvideo,audio/vnd.rn-realaudio,audio/x-pn-realaudio,video/x-ms-wmv,audio/mpeg,video/mpg,video/mpe,video/x-ms-asf,video/x-m4v
Detail   Only files of type video/mp4,video/mpeg,video/quicktime,video/x-msvideo,video/x-sgi-movie,video/avi,video/vnd.vivo,application/vnd.rn-realmedia,video/vnd.rn-realvideo,audio/vnd.rn-realaudio,audio/x-pn-realaudio,video/x-ms-wmv,audio/mpeg,video/mpg,video/mpe,video/x-ms-asf,video/x-m4v can be uploaded. Verify that you are uploading a file of the appropriate type.
Message  The MIME type or the Extension of the uploaded file application/octet-stream was not accepted by the server.
MimeType     application/octet-stream
Daniel Cook
  • 1,033
  • 1
  • 9
  • 19
  • Adobe made several changes to how `` works in ColdFusion 10. Could you please include your `` code? – Miguel-F Mar 13 '14 at 17:46
  • You may also want to make sure your mime type is in the server you are working on. – Cory Fail Mar 13 '14 at 17:49
  • I have edited the original question to include code - @Cory Fail, where would I look? This is my original question, where does CF get the information from? It is specified in Apache as above – Daniel Cook Mar 14 '14 at 08:30

2 Answers2

6

I will have to speculate until I can see your <cffile> code but my guess is that you have not allowed the appropriate mime type under the accept attribute of the <cffile> tag.


Now that you have included your code my assumption has been confirmed: you have not allowed the appropriate mime type under the accept attribute of the <cffile> tag.

See below for further details.

Several changes were made to how the <cffile> tag works in ColdFusion 10. You may or may not be aware that in ColdFusion 10 they added the strict attribute to the tag (documentation reference).

  • When strict is true, only MIME types or a combination of MIME types and extensions are allowed in the accept attribute. Since strict is true by default, you should specify MIME types for the accept attribute.
  • When strict is false, either MIME types or extensions or a combination of both can be specified as a value to the accept attribute. For more information, see this blog entry.

Not only was that attribute added, but the default value for the strict attribute is true. So because you have not specified it within your code it is on.

Note: If you receive an error like "The MIME type of the uploaded file (image/jpeg) was not accepted by the server", enter accept="image/jpeg" to accept JPEG files.

Taken from the Adobe documentation here. From the error message that you have posted an attempt was made to upload a file with mime type of "application/octet-stream". You appear to be expecting "video/x-ms-wmv". So you can try to figure out why your browser is attempting to upload the file as "application/octet-stream" or add that mime type to your accept attribute. WARNING: that will also allow other types of files to be uploaded that you probably don't want.

The cffile accept attribute uses the mime type that your browser sends to the server. Read that again... your browser tells cffile what the mime type is. It's very easy to spoof the mime type

Taken from Pete Freitag's page on Tips for Secure File Uploads with ColdFusion. (An older article but still has relevant tips.)

A couple of other references I found that may be helpful:

Regular Jo
  • 5,190
  • 3
  • 25
  • 47
Miguel-F
  • 13,450
  • 6
  • 38
  • 63
  • If it wasn't in the accept list, wouldn't it say "video/x-ms-wmv" was not accepted, instead of "application/octet-stream". I've already made attempts at figuring out if the browser is causing the issue - I checked the header, and my registry settings. Are you certain the error is due to the browser? – Daniel Cook Mar 14 '14 at 08:39
  • The issue is, as the error states, that the mime type of the uploaded file is "application/octet-stream" not "video/x-ms-wmv". I tried to point out in my answer that it is the user's browser that sends the mime type to the ColdFusion server. The CF server does not actually determine the mime type, it uses what the browser sends and the file extension of the file. Did you read the references that I included? They give more information about the process. Does your client machine support the "video/x-ms-wmv" mime type? If not, it probably does not know what mime type to send. – Miguel-F Mar 14 '14 at 12:44
  • You say that you checked the headers on your client machine. What mime type was sent from the client? See this [related answer to another question](http://stackoverflow.com/a/12061617/1636917) regarding mime types of uploaded files. – Miguel-F Mar 14 '14 at 12:46
  • It's already in the original post - Content-Disposition: form-data; name="fv_file"; filename="blahblah.wmv" Content-Type: video/x-ms-wmv – Daniel Cook Mar 14 '14 at 16:03
  • Also as in the original post I checked the registry for the entry which exists and HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.wmv - the content type for this entry says video/x-ms-wmv - the WMV file also plays on the client. – Daniel Cook Mar 14 '14 at 16:05
  • What are your client and server environments? Are these Windows machines? I'm guessing not as WMV files would be supported by default. – Miguel-F Mar 14 '14 at 17:08
  • Have tried on multiple windows clients (my own being windows 7), the server is a unix based o/s with CF10 + Apache – Daniel Cook Mar 14 '14 at 20:18
  • Thank you for your help Miguel, adding strict="false" does resolve the issue. It was my fault that I didn't get there sooner, I misread the explanation of how the strict attribute affected it. Thanks for you help and patience. – Daniel Cook Mar 17 '14 at 08:46
  • @DanielCook - yes that will get it working but be sure you understand what setting strict to "false" does. **When strict is true**, only MIME types or a combination of MIME types and extensions are allowed in the accept attribute. Since strict is true by default, one should specify MIME types for the accept attribute. **When strict is false**, either MIME types or extensions or a combination of both can be specified as a value to the accept attribute. I read that as - when `strict="false"` the MIME type will not be verified if the file extension is accepted, and vice-versa. – Miguel-F Mar 17 '14 at 11:48
  • The upload is behind a secured login, I think I will put further analysis on hold. It still prevents incorrect file-types uploaded. The admin won't be trying to spoof it. – Daniel Cook Mar 17 '14 at 13:30
0

You may have some odd mime type. If you use a try/catch block around your tag, you can display the full error message.

Example:

<cftry>
    <cffile accept="video/x-ms-wmv" action="upload" destination="#ExpandPath('/client-images/')#" filefield="form.UploadFile" nameconflict="makeunique">
    <cfcatch type="any">
        <cfdump var="#cfcatch#" label="cfcatch">
    </cfcatch>
</cftry>

The dump will display the mime type that ColdFusion thinks that was uploaded.

This is for development/analysis only, you wouldn't want to present the dump to regular site visitors.

Scott Jibben
  • 2,229
  • 1
  • 14
  • 22
  • Added to the original post, thanks - same error as I posted at the start of my post – Daniel Cook Mar 14 '14 at 08:34
  • Miguel-F seems to have a pretty complete answer or suggestions of where to look next. If you get it figured out, please make a note of it with this question, thanks! – Scott Jibben Mar 15 '14 at 05:46