0

I'm trying to do a simple task. Upload a file with valums file uploader (or fine-uploader) with MVC3 application, save it in database, and let user download it again (with an action returning FileContentResult), but to do that, I need the contentType of file uploaded.

IE9 uses the "UploadHandlerForm" methods in vlaums file uploader (I'm using version 2.1.2), where I can't get the contentType.

When I'm using IE10 for example, the plugin uploads using UploadHandlerXhr, so I can get the content type and post it to the server, with that:

_upload: function(id, params)
{
    ...
    var file = this._files[id];
    var type = (file.fileSize != null ? file.fileSize : file.size);

    ....
    //and then, add it to be posted to server:
    xhr.setRequestHeader("X-File-Type", type);
}

Is there any way I cant get the contentType of the file from an input file with javascript in older browsers (like IE9)?

Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
IPValverde
  • 2,019
  • 2
  • 21
  • 38

1 Answers1

0

It's not clear what you are trying to do here at all. Are you trying to send the content-type of the file in a separate request? If so, why? The content-type is part of each MPE request. Just examine the Content-Type header of the multipart boundary that contains the file data.

Also, don't access variables/functions that start with an underscore. Those are not part of the API and may change or be removed at any time. In the future, I hope to prevent access to these internal entirely.

Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
  • I'm just trying to get the content type of file in IE9 using valum file uploader (one of the most famous javascript plugins for assynchronous file upload, like attach a file to email while you write your message). The upload request itself, comes with "multipart/form-data" as value for content-type in header. And the form submission has content-type: "application/x-www-form-urlencoded"... – IPValverde Feb 25 '13 at 23:11
  • Yes, I'm aware of this. I maintain that uploader. As I mentioned, you can parse the content-type of the actual file by examining the content-type header of the multipart boundary (inside the request payload) that contains the file data. This should be very easy to do in virtually any server-side language. Have a look at the [server repo](https://github.com/Widen/fine-uploader-server) in the Github project for some examples. Also, the version of Fine Uploader is quite old. Consider upgrading – Ray Nicholus Jul 09 '13 at 20:15