zoukankan      html  css  js  c++  java
  • MVC上传(单文件)

    后台代码:

     public ActionResult upload()
            {
                //获取文件对象
                var file = Request.Files[0];
                string suffix/*文件格式*/ = System.IO.Path.GetExtension(file.FileName);
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + suffix;
                string saveDic = "/upload/";
                if (file != null)
                {
                    if (!Directory.Exists(Server.MapPath(saveDic)))
                    {
                        Directory.CreateDirectory(Server.MapPath(saveDic));
    
                    }
                    file.SaveAs(Server.MapPath(saveDic) + fileName);
                    
                    return Content("<script>alert('添加成功!')</script>");
                }
                else
                {
                    return Content("0");
                }
            }
    

     前台代码:

    <form action="/test/upload" enctype="multipart/form-data" method="post">
        <input type="file" name="file" />
        <button id="upload">确定</button>
    </form>
    
  • 相关阅读:
    BSGS
    聪聪可可(未完成)
    强连通分量,缩点
    bozj 1823(未完成)
    网络流
    bzoj1026
    点分治 poj1741
    bzoj 3270 博物馆
    高斯消元 模板
    bzoj 3143 [Hnoi2013]游走
  • 原文地址:https://www.cnblogs.com/gaocong/p/4816593.html
Copyright © 2011-2022 走看看