ASP.NET 2.0 多檔案上傳小經驗

iDotNetSpace發表於2010-01-22
我做的試驗程式碼:





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部落格 ” ,連結:http://blog.itpub.net/12639172/viewspace-625751/,如需轉載,請註明出處,否則將追究法律責任。

相關文章