. Net mvc4 + ajaxfileupload. js solves the problem of the pop-up Download Dialog Box in IE browser, ajaxfileupload. js

Source: Internet
Author: User

. Net mvc4 + ajaxfileupload. js solves the problem of the pop-up Download Dialog Box in IE browser, ajaxfileupload. js

Abstract: Everyone encounters different problems. I have not solved my problems after finding a large circle on the Internet! This problem is solved because my environment is shown in the title.
Main problem: the setting of the Response Header


        [HttpPost]        public ContentResult UploadFile(string user = WinTabConst.Space, int type = ConfigConst.Zero, string imgType = WinTabConst.Space, int objId = ConfigConst.Zero, DateTime? createDateTime = null)        {            HttpPostedFileBase imgFile = Request.Files["imgFile"];            AttachmentBLL attachmentBll;            if (!string.IsNullOrEmpty(user))                attachmentBll = new AttachmentBLL(user);            else                attachmentBll = new AttachmentBLL();            int userId = 0;            users userModel = attachmentBll.CurUser;            if (user != null)                userId = userModel.UserID;            return Content(JavascriptHelper.JsonSerializer.Serialize(attachmentBll.UploadFile(true, "", imgFile, type, imgType, objId, userId, createDateTime)));        }


$. AjaxFileUpload ({url: "/Companies/attachment/UploadFile", data: {"objId": objId, "createDateTime": createDateTime, "dir": "", "type ": "2", "userid": UserID, "user": $. cookie ('logininfo')}, type: "post", secureuri: false, dataType: "text", fileElementId: "imgFile", success: function (data) {if (data! = Null & data = "") {// The result is that the format is json and the data received by IE is "", but the figure shows a successful transfer problem $ (". uploadImg "). hide (); $ (". mask "). hide ();} else if (data! = Null & data. error = 0) {// my correct execution method $ (". uploadImg "). hide (); $ (". mask "). hide ();} else {AlertAlert ("Upload Failed! ") ;}}, Error: function (e) {$. messager. alert (" prompt "," Operation error! ");}});

In ajaxfileUploadjs, jQuery (form) submit (); ie does not go to the background, and other browsers do. Why?

File selected files are directly triggered by file files, which I have encountered before:
Create a file control when a button is clicked, and then file. click ()
This method is fine for browsers other than IE, but you must click file in IE to upload the file successfully. I will not explain the security issues that everyone knows.
Solution: create a file and click the file control to trigger the file selection. If you think the file looks bad, OK is transparent and then set the style you want, you should understand it as a smart person. Two images: (this is irrelevant to the background)

Images cannot be uploaded all the time. If you want to, I will send you an email!

Note: If you don't give a score for such a hard job, you won't be able to give it a score !!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.