溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

解決AjaxFileupload 上傳時會出現(xiàn)連接重置的問題

發(fā)布時間:2020-09-25 17:18:08 來源:腳本之家 閱讀:181 作者:namedL 欄目:web開發(fā)

1.ajaxfileupload 上傳時會出現(xiàn)如下問題:

解決AjaxFileupload 上傳時會出現(xiàn)連接重置的問題

2. 網(wǎng)上有很多的解決辦法,在這里,我又發(fā)現(xiàn)了一種,可能你的錯誤會是這個原因引起的

------原因是 : 你在一般處理程序中沒有返回前臺需要的數(shù)據(jù)格式字符串

3.下面給出一個例子:

前臺:

<style type="text/css">
    .fileLink{position: relative;display: inline-block;background: #fff;border: 1px solid #0980D0;border-radius: 4px;padding: 2px 8px;margin-left:10px;margin-top:10px;overflow: hidden;color: #1E88C7;text-decoration: none;text-indent: 0;line-height: 20px;}
    .fileLink input {position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;}
    .fileLink:hover {background: #AADFFD;border-color: #78C3F3;cursor:pointer;color: #004974;text-decoration: none;}
  </style>
<span class="fL fileLink" >選擇文件<input type="file" id="uploadify" name="uploadify" value="上傳數(shù)據(jù)" /></span>
<script src="../../Plugins/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="../../Plugins/ajaxfileupload.js" type="text/javascript"></script>
<script>
    $("#uploadify").on("change", function () {
      //var file = $("#uploadify")[0].files[0];
      $.ajaxFileUpload({
        url: './ImportDynamic.ashx',
        fileElementId: 'uploadify',
        dataType: 'text',
        success: function (data, status) {
          alert(1);
        },
        error: function () { }
      });
    });
</script>
一般處理程序:
      context.Response.ContentType = "text/plain";
      var filePath = "uploadfile/xxx.xls";
      filePath = context.Server.MapPath(filePath);
      Import.GetCommonReportFile(filePath);
      //context.Response.Write("返回文本數(shù)據(jù),否則前臺就會報(bào)如上錯誤");

4.插件:http://files.cnblogs.com/files/namedL/ajaxfileupload.js

以上所述是小編給大家介紹的解決AjaxFileupload 上傳時會出現(xiàn)連接重置的問題,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對億速云網(wǎng)站的支持!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI