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

推荐订阅源

Help Net Security
Help Net Security
G
Google Developers Blog
雷峰网
雷峰网
WordPress大学
WordPress大学
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Engineering at Meta
Engineering at Meta
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
AWS News Blog
AWS News Blog
F
Full Disclosure
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
J
Java Code Geeks
U
Unit 42
C
Cyber Attacks, Cyber Crime and Cyber Security
V
V2EX
C
Cisco Blogs
博客园 - 司徒正美
Project Zero
Project Zero
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
Scott Helme
Scott Helme
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog
S
Securelist
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
S
Schneier on Security
G
GRAHAM CLULEY
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyberwarzone
Cyberwarzone
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
T
Threatpost
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
The Register - Security
The Register - Security
S
Security Archives - TechRepublic
博客园 - Franky
N
News | PayPal Newsroom
Simon Willison's Weblog
Simon Willison's Weblog
S
SegmentFault 最新的问题
W
WeLiveSecurity
A
Arctic Wolf
B
Blog

博客园 - 小林子

jQuery技术简介 在ASP·NET中实现页面之间的传参 Remoting简介 xml简介 关于CSS XAML简介 什么是WCF 泛型的优点 COBOL语言简介 OOP是什么? C#与VB.net的不同 vss Ajax的工作原理 Ajax优点和缺点 DetailsView中编辑内容的设置内容和获取内容的方法 实现上传图片之后显示预览javaScript代码 在页面中通过地址栏传值的方法 一般后台执行类的写法 GridView的用法总结(代码收藏)
上传图片到服务器中的代码(并把图片的名字用当前时间来代替)
小林子 · 2008-04-20 · via 博客园 - 小林子

  这是用来处理图片名字的方法, 他返回一个string的类型,返回的就是要存入数据库中的路径

    /// 用来处理图片的名字,用事件作为图片的名字
    /// </summary>
    /// <returns></returns>
    private string Upload()
    {
        string strDate = DateTime.Now.ToString();
        strDate = strDate.Replace("-", "");
        strDate = strDate.Replace(":", "");
        strDate = strDate.Replace(" ", "");

        string strFileName = this.File1.PostedFile.FileName;

        int nLength = strFileName.Length - strFileName.LastIndexOf(".");
        strFileName = strDate + strFileName.Substring(strFileName.LastIndexOf("."), nLength);//取文件名
        string strPath = Server.MapPath(".") + "\\Upload\\";
        this.File1.PostedFile.SaveAs(strPath + strFileName);//上载文件
        return "Upload/" + strFileName;//返回图片的url相对路径
    }