FileUpload - 选择文件,不能执行上传功能,通过点击按钮实现上传

默认选择类型为所有类型

C#-WebForm-文件上传-FileUpload控件

//<上传>按钮
    void Button1_Click(object sender, EventArgs e)
    {
        //判断是否选中文件
        if (FileUpload1.FileName.Length <= 0)
        {
            Label1.Text = "未选中任何文件!";
            return;
        }
        //<上传> 功能代码
        //------------------------------------------------------
        //新建文件夹Uploads,设置保存文件名和类型abc.txt
        string path = "Uploads/abc.txt";
        //映射绝对路径(Server.MapPath())
        string endpath = Server.MapPath(path);//映射绝对路径
        //展示上传保存文件夹绝对路径
        Label1.Text = endpath;
        //保存到服务器(SaveAs())
        FileUpload1.SaveAs(endpath);//保存到绝对路径
        //------------------------------------------------------
    }
<上传>按钮

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2021-05-16
  • 2021-11-22
猜你喜欢
  • 2021-11-10
  • 2021-11-20
  • 2021-11-25
  • 2021-07-23
  • 2021-12-11
  • 2021-07-23
  • 2022-12-23
相关资源
相似解决方案