zoukankan      html  css  js  c++  java
  • 多文件上传 from 达达

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Demo._Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script language="JavaScript">
    function addFile()
    {
     
    var str = '<INPUT type="file" size="50" NAME="File">
    '
     document.getElementById('MyFile').insertAdjacentHTML(
    "beforeEnd"
    ,str)
    }

    </script>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        
    <title>Untitled Page</title>
    </head>
    <body>
        
    <form id="form1" runat="server" enctype="multipart/form-data">
               
    <input type="button" value="增加(Add)" onclick="addFile()">
              
    <input onclick="this.form.reset()" type="button" value="重置(ReSet)">
              
    <asp:Button Runat="server" Text="上传" ID="Upload" OnClick="Upload_Click1" ></asp:Button>
        
    <div id="MyFile">
             
    <input type="file" name="File" /> 
        
    </div>

        
    </form>
    </body>
    </html>

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    namespace Demo
    {
        
    public partial class _Default : System.Web.UI.Page
        
    {
            
    protected void Page_Load(object sender, EventArgs e)
            
    {
            }

            
    protected void Upload_Click1(object sender, EventArgs e)
            
    {

                HttpFileCollection _files 
    = System.Web.HttpContext.Current.Request.Files;

                
    for (int i = 0; i < _files.Count; i++)
                
    {
                    _files[i].SaveAs(Server.MapPath(
    "~/Files/" + _files[i].FileName));
                }

            }

        }

    }
  • 相关阅读:
    Message Flood SDUT 1500
    SDUT1482——二元多项式
    SDUT—2057 模拟题
    Eight(bfs+全排列的哈希函数)
    Pick-up sticks(判断两条线段是否相交)
    poj 1265 Area(pick定理)
    poj 2503 Babelfish(字典树哈希)
    poj 3007 Organize Your Train part II(静态字典树哈希)
    Surprising Strings(map类)
    Strange Way to Express Integers (一般模线性方程组)
  • 原文地址:https://www.cnblogs.com/kevinge/p/1247754.html
Copyright © 2011-2022 走看看