• 最简单的上传文件


    前台

    1       <div class="upload">
    2           <asp:FileUpload ID="FileUpload1" runat="server"/>
    3           <asp:Button ID="BtnLoad" runat="server" Text="上传" onclick="BtnLoad_Click"/>
    4      </div>
    View Code

    后台

     1   protected void BtnLoad_Click(object sender, EventArgs e)
     2         {
     3             if (this.FileUpload1.FileName == "")
     4             {
     5                 Response.Write("<script>alert('没有上传文件')</script>");
     6                 return;
     7             }
     8             DataAccess.dataDR datadr = new dataDR();
     9             datadr.delete("delete from dbo.autozhesuanxisubiao");
    10             string fileName = DateTime.Now.ToString("yyMMddhhmmss") + ".xls";
    11             string path = Server.MapPath("~/upload/excel/") + fileName;
    12             FileUpload1.SaveAs(path);
    13 
    14             if (path != null)
    15             {
    16                 DataAccess.LoadSourceToDataAccess.loadAutoZhesSuangXiShu(path);
    17                 Response.Write("<script>alert('上传成功!')</script>");
    18             }
    19             else
    20             {
    21                 Response.Write("<script>alert('没有上传文件')</script>");
    22             }
    23         }
    View Code
  • 相关阅读:
    Vue_使用v-model指令写的简易计算器
    Vue_v-for的四种用法示例
    bs4_加载顺序
    Vue_自定义指令
    Vue_v-for中key的使用注意事项
    Vue_指令
    bs4_card(卡片)
    Vue_过滤器
    Vue_生命周期函数
    selenium 文件上传
  • 原文地址:https://www.cnblogs.com/yuanjiehot/p/4349057.html
Copyright © 2020-2023  润新知