需要下载NeatUpload插件

上传页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="Brettle.Web.NeatUpload" Namespace="Brettle.Web.NeatUpload"
  TagPrefix="Upload" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
   <link href="easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
  <link href="easyui/themes/icon.css" rel="stylesheet" type="text/css" />
  <script src="/UploadFiles/2021-04-02/jquery.min.js">

后台源码:

protected void BtnUP_Click(object sender, EventArgs e)
  {
    if (AttachFile.HasFile)
    {
      string FileName = this.AttachFile.FileName;//获取上传文件的文件名,包括后缀
      string ExtenName = System.IO.Path.GetExtension(FileName);//获取扩展名
      string SaveFileName = System.IO.Path.Combine(System.Web.HttpContext.Current.Request.MapPath("UpLoads/"), DateTime.Now.ToLongDateString().ToString() + "-" + FileName);//合并两个路径为上传到服务器上的全路径
      AttachFile.MoveTo(SaveFileName, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
      string url = "UpLoads/" + DateTime.Now.ToString("yyyyMMddhhmmss") + ExtenName; //文件保存的路径
      float FileSize = (float)System.Math.Round((float)AttachFile.ContentLength / 1024000, 1); //获取文件大小并保留小数点后一位,单位是M
      Response.Write("<script>alert('恭喜您,上传成功!')</script>");
    }
    else
    {
      Response.Write("<script>alert('请选择文件!')</script>");
    }
  }

这里直接获取上传文件夹文件名称提供下载

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Down.aspx.cs" Inherits="Down" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
  <link href="easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
  <link href="easyui/themes/icon.css" rel="stylesheet" type="text/css" />
  <script src="/UploadFiles/2021-04-02/jquery.min.js">

以上就是本文的全部内容,希望对大家的学习有所帮助。

标签:
asp.net大文件上传,asp.net文件上传,asp.net上传,asp.net多文件上传

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com

评论“ASP.NET实现大文件上传功能”

暂无“ASP.NET实现大文件上传功能”评论...