添加图片

 /// <summary>
        /// 添加人员信息
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        // POST: ErShi/Create
        [HttpPost]
        public int Create(People model,HttpPostedFileBase PTX)
        {
            string path = Path.Combine(Request.MapPath("/Img/"), PTX.FileName);
            PTX.SaveAs(path);
            model.PTX = "/Img/" + PTX.FileName;
            return bll.AddInfos(model);
        }

 

        <h1>添加人员信息</h1><hr />
        @using(Ajax.BeginForm("Create","",new AjaxOptions { }))
        {
         
            <span>头像:</span>@Html.TextBoxFor(m => m.PTX,new {@type="file" })<br /><br />
            <input id="Button1" type="button" value="保存" class="btn-primary"/>
        }
    </div>

     <script>
    $(function () {
        $("#Button1").click(function () {
            $("#form0").ajaxSubmit({
                url: "/ErShi/Create",
                type: "post",
                success: function (data) {
                    if (data > 0) {
                        alert("添加成功!");
                        location.href = "/ErShi/Index";
                    }
                }
            })
        })
    })
</script>

 

posted on 2018-08-22 15:52  菜鸟兵  阅读(337)  评论(0)    收藏  举报

导航