1

I am using blueimp jQuery-File-Upload with MVC3 .NET, i have the next action in my controller.

    [HttpPost]
    public ContentResult UploadImageEditor(HttpPostedFileBase file)
    {
        if (file == null) return null;

        string fileName = Path.Combine(Server.MapPath("~/Content/img/user"), file.FileName);

        file.SaveAs(fileName);

        return new ContentResult
        {
            ContentType = "text/plain",
            Content = "/Content/img/user/" + file.FileName,
            ContentEncoding = Encoding.UTF8
        };
    }

And in my view i have:

<input id="fileupload" type="file" name="files[]" data-url="/Document/UploadImageEditor/" multiple>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../../Content/jquery-ui-1.10.4/jquery-ui-1.10.4/ui/jquery.ui.widget.js"></script>
<script src="../../Content/jquery-ui-1.10.4/jquery.iframe-transport.js"></script>
<script src="../../Content/jQuery-File-Upload-9.5.4/jQuery-File-Upload-9.5.4/js/jquery.fileupload.js"></script>

<script>
    $(function () {
        $('#fileupload').fileupload({
            dataType: 'text',
            done: function (e, data) {
                $.each(data.result.files, function (index, file) {
                    $('<p/>').text(file.name).appendTo(document.body);
                });
            }
        });
    });
</script>

It's working correctly in Chrome but when try in IE9 the parameter file in my controller is always null.

I tried put the input file into a form but does not work too.

Anyone has any ideas

Thanks in advance.

systems
  • 49
  • 2
  • 10

1 Answers1

0

You should try:

done: function (e, data) {
    $.each(data.files, function (index, file) {
        $('<p/>').text(file.name).appendTo(document.body);
    });
}

I think IE9 use IframeTransport option, I tested with forceIframeTransport: true, and the data.result value is sometimes empty, whereas data.file is always the same.

Fractaliste
  • 5,777
  • 11
  • 42
  • 86