日期:2014-05-17  浏览次数:20482 次

使用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就可以了