惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog
WordPress大学
WordPress大学
Jina AI
Jina AI
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
腾讯CDC
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
Google DeepMind News
Google DeepMind News
月光博客
月光博客
博客园 - Franky
Y
Y Combinator Blog
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
雷峰网
雷峰网
小众软件
小众软件
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - gengen

asp.net程序中最常用的三十三种编程代码 js+xml dataset读取xml 下拉 flash实现 js+xml DataList分页(与Repeater控件的例子相似,都以pubs数据库中的authors为例) Datalist分页 datagrid 绑定与简单分页 asp.net 常用文件上传下载 转的 批量删除 移动控件 可拖放控件的使用 国家公务员考完了 RegularExpressionValidator javascript中模拟hashtable对数组进行快速查找 网页中提交按钮倒记时的实现 原作:mlg js技巧 WEB标准开发中的一些基本用法(连载中...)
简单上传
gengen · 2006-12-27 · via 博客园 - gengen

private void Button1_Click(object sender, System.EventArgs e)
  {
   string name=this.File1.PostedFile.FileName;
  string filename=name.Substring(name.LastIndexOf("\\")+1);
this.File1.PostedFile.SaveAs(Server.MapPath("upfile")+"\\"+filename);
  }

string name = upFileUpload1.FileName; //获取已上传文件夹的名字
        string size = upFileUpload1.PostedFile.ContentLength.ToString(); //获取已上传文件夹的大小
        string type = name.Substring(name.LastIndexOf("."+ 1); //得到文件的后缀

        
string ipath = Server.MapPath("up"+ "\\" + name; //获取文件夹上传的实际路径
        string fpath = Server.MapPath("upfile"+ "\\" + name; //获取文件夹上传的实际路径
        string wpath = "up\\" + name;                          //写入到数据库去的虚拟路径//下面我们得判断文件格式
        if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
        {
            upImage1.Visible 
= true;
            upFileUpload1.SaveAs(ipath); 
//将文件保存到path这个路径里面
            upImage1.ImageUrl = wpath;   //让图片显示出来
            upLabel1.Text = "你传的文件名称是:" + name + "<br>文件大小为:" + size + "字节<br>文件类型是:" + type + "<br>后缀名是:" + type + "<br>实际路径是:" + ipath + "<br>虚拟路径是:" + wpath;
        }
        
else
        {
            upImage1.Visible 
= false//将图片控件隐藏,否则它会出现一个小XX
            upFileUpload1.SaveAs(fpath); //将文件夹保存在另一个文件夹
            upLabel1.Text = "你传的文件名称是:" + name + "<br>文件大小为:" + size + "字节<br>文件类型是:" + type + "<br>后缀名是:" + type + "<br>实际路径是:" + ipath + "<br>虚拟路径是:" + wpath;
        }