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

推荐订阅源

罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
博客园 - 三生石上(FineUI控件)
V
V2EX
有赞技术团队
有赞技术团队
V
Visual Studio Blog
小众软件
小众软件
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
量子位
T
Tailwind CSS Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Palo Alto Networks Blog
Cisco Talos Blog
Cisco Talos Blog
I
Intezer
Project Zero
Project Zero
A
Arctic Wolf
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
L
Lohrmann on Cybersecurity
S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tor Project blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Security @ Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 热门话题
G
GRAHAM CLULEY
Help Net Security
Help Net Security
N
News | PayPal Newsroom
W
WeLiveSecurity
G
Google Developers Blog
Microsoft Security Blog
Microsoft Security Blog
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
C
Check Point Blog

博客园 - melody&bobo

C#加密解密 端口数据库连接 ANSI, UNICODE,UTF8编码的区别 调用系统API打印图片文字 windows2003安全设置 图片与字节数组相互转换的方法 jQuery Ajax 方法调用 Asp.Net WebService 的详细例子 使用instantclient_11_2和PL/SQL Developer工具包连接oracle 11g远程数据库 查看SQL 语句执行性能 SSIS 获取时间表达式 获得时间段之间每月的最后一天 ADSL拨号获得不同IP地址 C#(.Net) 解决Informix中文乱码问题 SQL SPLIT() 方法实现 JS获取URL参数值 datatable操作集合 nginx实现网站负载均衡测试实例(windows下IIS做负载实测) Web Application Stress Tool(WAS,Web应用负载测试工具)详细说明 Base64 加密字符串和文件
表单提交文件 - melody&bobo - 博客园
melody&a · 2010-09-17 · via 博客园 - melody&bobo

代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    
<title>无标题页</title>
    
<script type="text/javascript">
    
function upfile() {
    
var form = document.dform;
    
// check the filename first
    var file = document.getElementById("ifile").value;
    
var pos = file.lastIndexOf('.');
    
var ext = file.substring(pos + 1).toLowerCase();
    
if (ext != 'jpg' && ext != 'gif' && ext != 'png')
    {
        alert(
'错误:您选择上传必须是 jpg/gif/png 文件!');
        
return;
    }
    
// replace form options
    var action = form.action;
    
var enctype = form.enctype;
    
var target = form.target;
    form.action 
="default3.aspx";
    form.enctype 
= 'multipart/form-data';
    
if (typeof form.encoding != 'undefined') form.encoding = 'multipart/form-data';
    form.submit();
    }
    
</script>
</head>
<body>
    
<form id="dform" name="dform"  method="post"  runat="Server">
    
<div>
        
<input id="ifile" name="ifile"  type="file"  onchange="upfile()"  />
        
</div>
    
</form>
</body>
</html>

代码

    protected void Page_Load(object sender, EventArgs e)
    {
        
if (Request.Files.Count > 0)
        {
            
string path = Server.MapPath("uploadfile/");
            HttpPostedFile postfile 
= Request.Files[0];
            
if (postfile.ContentLength > 0)
            {
                
string name = DateTime.Now.ToString("yyMMddHHmmssfff"+ postfile.FileName;
                postfile.SaveAs(path 
+ name);
                Page.ClientScript.RegisterStartupScript(
this.GetType(), "js""<script>printimage('uploadfile/" + name + "')</script>");
            }
        }
    }