解决AjaxFileupload 上传时会出现连接重置的问题
1.ajaxfileupload 上传时会出现如下问题:

2. 网上有很多的解决办法,在这里,我又发现了一种,可能你的错误会是这个原因引起的
------原因是 : 你在一般处理程序中没有返回前台需要的数据格式字符串
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" style="padding-left: 10px;">选择文件<input type="file" id="uploadify" name="uploadify" value="上传数据" /></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("返回文本数据,否则前台就会报如上错误");4.插件:http://files.cnblogs.com/files/namedL/ajaxfileupload.js
相关推荐
ajaxyan 2013-09-12
yFifhting 2015-04-13
wujiajax 2015-04-10
XuDTone 2015-04-07
dlcshjw 2019-04-19
XIAyuzheng 2018-08-23
wmsjlihuan 2019-04-14
maidou0 2015-03-10
为了美观,把 type="file" 控件隐藏。点击“上传”按钮,click调用隐藏文件控件,再选择文件。查了一遍,好像是ie为了安全控制,文件的必须鼠标点击过后,才能提交。还没有想到其他的方法。。。
BluewineY 2013-06-17
kentrl 2018-08-23
dalong 2016-07-28
5,success 提交成功后自动执行的处理函数,参数data就是服务器返回的数据。6,error 提交失败自动执行的处理函数。7,data 自定义参数。fileElementId: 'file1',
daydream000 2016-03-21
longshengguoji 2015-12-08
Ardencyz 2015-09-25
ghjcduhvfyjhbf 2015-09-24
learningever 2015-08-07
Balalala 2015-04-13
shumark 2015-04-10
shumark 2015-04-07