jquery.fileupload上传ASP.NET mvc方法中怎么获取不到文件!!!!

liu_lxx liu_lxx 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
视图中代码:
<input class="jqfileupload" type="file" name="file[]" data-url="@Url.Action("UpLoad","Company")" accept="image/png, image/gif, image/jpg, image/jpeg" multiple>


script代码:
    function jqfileupload(objs) {
objs.fileupload({
data: 'json',
done: function (e, data) {
alert('asdf');
jQuery.each(data.result.files, function (index, file) {
alert(file.name);
});
},
fail: function (e, data) {
jQuery.alerts.dialogClass = 'alert-danger';
jAlert("文件上传失败", "上传失败", function () {
jQuery.alerts.dialogClass = null; // reset to default
});
jQuery('.fileuploadprocess', data.context.parent()).remove();
data.context.html('<i class="iconfa-off"></i>重新上传');
data.context.show();
return false;
},
process: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);

jQuery('.bar', data.context.parent()).css(
'width',
progress + '%'
);
},
add: function (e, data) {
alert(data);
jQuery(e.target).prev('span').text('重新选择');
jQuery(e.target).parent().parent().children('strong').text(data.files[0].name);

jQuery(e.target).parent().parent().children('a').remove();
data.context = jQuery('<a href="javascript:void(0)" class="btn btn-info btn-rounded"><i class="iconfa-off"></i>开始上传</a>')
.appendTo(jQuery(e.target).parent().parent())
.click(function () {
jQuery(this).parent().append(jQuery('<div class="progress progress-striped active fileuploadprocess">\
<div style="width: 45%" class="bar">上传中</div>\
</div>'));
jQuery(this).hide();
data.submit();
});
},
});
}
jqfileupload(jQuery('input.jqfileupload'));


MVC对应的方法:
public string UpLoad() 
{
HttpFileCollectionBase hfc = Request.Files;
List<string> retUrl = UpLoadHelper.Upload(hfc);
return retUrl[0];
}


调试图片:

网上查了好多资料都没看见.net后台获取的方法,是大家都没这个问题么?才用MVC两周,小白求指导!!!
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
liu_lxx
.NET社区 62,271 成员 668,968 内容