读书人

使用ajaxfileupload插件上传资料取不到

发布时间: 2013-09-28 10:01:20 作者: rapoo

使用ajaxfileupload插件上传文件取不到值
不知道问题在哪,求解
就一个文件框

<input type="file" id="fuLiveD" class="fileT" />


js这样写的

$(".fileT").live("change", function () {
var $img = $(this).parent().parent().find("img");
var id = $(this).attr("id");
$.ajaxFileUpload({
url: "SaveFileInfo.ashx",
secureuri: false,
fileElementId: 'fuLiveD', //文件选择框的id属性
dataType: 'json', //服务器返回的格式,可以是json
success: function (data, status) {
$('#result').html('添加成功');
}
});
});


后台是这样

context.Response.ContentType = "text/html";
HttpFileCollection hpf = HttpContext.Current.Request.Files;
string uploadpath = context.Server.MapPath("~/Img/member");
hpf[0].SaveAs(uploadpath+"/"+hpf[0].FileName);
return hpf[0].FileName;


调试运行到后台的时候hpf总是没有值,已经被折磨了一天了。 javascript ajax asp.net jquery
[解决办法]
HttpPostedFile file = context.Request.Files["Filedata"];
[解决办法]
<input type="file" id="fuLiveD" class="fileT" name="fuLiveD" />

给file一个name就可以了

读书人网 >asp.net

热点推荐