码迷,mamicode.com
首页 > 其他好文 > 详细

shang

时间:2017-11-22 13:08:13      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:turn   value   else   str   sub   tor   ring   return   string   

    <div>
        <form action="fileUpload" method="post" enctype="multipart/form-data">
            <table>
                <tr>
                    <td>请选择文件</td>
                    <td><input type="file" name="Excelname" value="" /></td>
                </tr>
                <tr>
                    <td>姓名:</td>
                    <td><input type="text" name="name" value="" /></td>
                </tr>
                <tr>
                    <td>类:</td>
                    <td><input type="text" name="lei" value="" /></td>
                </tr>
                <tr>
                    <td>班级:</td>
                    <td><input type="text" name="lei" value="" /></td>
                </tr>
                <tr>
                    <td>性别:</td>
                    <td><input id="Radio1" type="radio" />男<input id="Radio1" type="radio" />女</td>
                </tr>
                <tr>
                    <td>年龄:</td>
                    <td><input type="text" name="name" value="" /></td>
                </tr>
                
                <tr>
                    <td><input type="submit" name="name" value="添加" /></td>
                </tr>
            </table>

        </form>
    </div>

public ActionResult fileUpload(HttpPostedFileBase Excelname, MVCmodel n)
        {
            if (Excelname == null)
            {
                return View();
            }
            string Fname = Server.MapPath("/EXCEL/");
            if (!Directory.Exists(Fname))
            {
                Directory.CreateDirectory(Fname);
            }
            string foldname = Path.GetFileName(Excelname.FileName);
            string Fnewname = string.Format("{0}.{1}", Guid.NewGuid().ToString(), foldname.Split(‘.‘)[1]);
            Excelname.SaveAs(Fname+Fnewname);
            sModel m = new sModel();
            m.Name = n.Name;
            m.AradeNo = m.AradeNo;
            m.ClassNo = n.ClassNo;
            m.Sex = n.Sex;
            m.Age = n.Age;
            m.FileName = Fnewname;
            var data = new BLL.sBLL().addinfos(m);
            if (data > 0)
            {
                return Content("<script>alert(‘上传成功‘);location.href=‘showList‘</script>");
                
            }
            else
            {
                return Content("<script>上传失败</script>");
            }
        }

 

shang

标签:turn   value   else   str   sub   tor   ring   return   string   

原文地址:http://www.cnblogs.com/jin68/p/7878496.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!