Solved

file upload results in download window in firefox and IE

Posted on 2009-05-06
7
222 Views
Last Modified: 2012-05-06
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
Comment
Question by:csetzkorn
  • 4
  • 2
7 Comments
 
LVL 7

Expert Comment

by:ycTIN
ID: 24323503
0
 

Author Comment

by:csetzkorn
ID: 24325752
Thanks for that. Do you know how to change the headers to be
content type HTML (as mentioned in this article)?

Thanks.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24325854
What is your server language? PHP/ASP/.NET?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:csetzkorn
ID: 24325893
I am using ASP.NET MVC

code:

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

Author Comment

by:csetzkorn
ID: 24326013
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
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 24326082
0
 

Author Comment

by:csetzkorn
ID: 24326550
Thanks. It was actually easier than that:

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now