ajaxfileupload上傳問題


1.ajaxfileupload上傳的時候出現錯誤,無法獲取錯誤信息,需要在ajaxfileupload.js的源碼中加入以下代碼

 handleError: function (s, xhr, status, e) {
        // If a local callback was specified, fire it
        if (s.error) {
            s.error.call(s.context || s, xhr, status, e);
        }

        // Fire the global callback
        if (s.global) {
            (s.context ? jQuery(s.context) : jQuery.event).trigger(
                    "ajaxError", [xhr, s, e]);
        }
    },

插入代碼的位置為

2.ajaxfileupload在上傳的時候如果需要進行傳遞參數的時候,需要在ajaxfileupload.js的源碼中修改以下代碼,改動如圖中標注位置

 

 3.當使用ajaxfileupload進行二級域名跨域上傳的時候,需要修改的內容為

(1) 調用上傳的html頁面所在域名是 www.abc.com ,添加document.domain

<script>
document.domain = "abc.com";
</script>

(2)上傳的服務端也需要進行document.domain注明

public ActionResult Upload()

{
        string  message =  "上傳成功,文件大小:"  + size;
 
             json =  new  JsonResult
             {
                 Data =  new
                 {
                     success =  true ,
                     message = message,
                     data =  new
                     {
                         name = name,
                         upload_name = upload_name,
                         extension = extension,
                         size = size,
                         url = url,
                         download_url = file_downloadpath + url
                     }
                 }
             };
             return  CrossDomainContent(json);
}
 
 
 
private  ContentResult CrossDomainContent(JsonResult json)
         {
             StringBuilder sb =  new  StringBuilder();
             sb.Append( "<script> document.domain = 'abc.com'; </script>" );
             sb.Append(JsonConvert.SerializeObject(json.Data));
             return  Content(sb.ToString());
         }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM