Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

file upload results in download window in firefox and IE

I am using this jquery code:

var options =
                {
                    url: '../Account/Upload',
                    type: 'POST',
                    contentType: 'multipart/form-data',
                    dataType: "text",
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        ...
                    },
                    success: function(data) {
                        ...
                    },
                    beforeSend: function() {
                        ...
                    },
                    semantic: false
                };

            // bind form using 'ajaxForm'
            $('#item_form').ajaxForm(options);

to upload files to the server, which works fine. I am using the forms plugin and the multifile upload plugin. I believe that the former plugin uses the 'iframe approach' to allow file upload. Unfortunately, I get file download popups in my browsers (tried firefox and IE) after the upload. E.g. firefox "You have chosen to open ...". I believe this has to do with the iframe stuff. Is there a way to avoid these pop ups?

Thanks.

Best wishes,

Christian
0
csetzkorn
Asked:
csetzkorn
  • 4
  • 2
1 Solution
 
csetzkornAuthor Commented:
Thanks for that. Do you know how to change the headers to be
content type HTML (as mentioned in this article)?

Thanks.
0
 
Michel PlungjanIT ExpertCommented:
What is your server language? PHP/ASP/.NET?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
csetzkornAuthor Commented:
I am using ASP.NET MVC

code:

[AcceptVerbs(HttpVerbs.Post)]
        public JsonResult Upload
        (
            HttpPostedFileBase file
)
{
 // save files works fine
}
0
 
csetzkornAuthor Commented:
This is what I get in Firefox after the upload - something similar occurs in IE.

I have also noticed that I can only retrieve the other standard form elements on the server side if the user chooses at least one file. Not sure why. The JSON data are send either way (detected via Firebug).

C
untitled.JPG
0
 
Michel PlungjanIT ExpertCommented:
0
 
csetzkornAuthor Commented:
Thanks. It was actually easier than that:

AcceptVerbs(HttpVerbs.Post)]
        public string Upload
        (
            HttpPostedFileBase file
)
{
 // save files works fine
}
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now