ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ASP.NET 2.0 多文件上传小经验

ASP.NET 2.0 多文件上传小经验

原创 Linux操作系统 作者:iDotNetSpace 时间:2010-01-22 10:58:09 0 删除 编辑
我做的试验代码:

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



function addFile()
{
var str = ' '
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str)
}



    Untitled Page


   
         
         
         
   

       
   

   



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));
            }
        }
    }
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-625751/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5766115