using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.IO;
public partial class admin_Default3 : System.Web.UI.Page
{
public static ArrayList files = new ArrayList();
protected void btnAdd_Click(object sender, EventArgs e)
{
if (fupFile.HasFile)
{
ListItem item = new ListItem();
item.Value = item.Text = fupFile.PostedFile.FileName;
if (!lbxFile.Items.Contains(item))
{
lbxFile.Items.Add(item);
files.Add(fupFile);
}
else
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "", @"<script>alert('不能添加已经添加过的文件!')</script>");
}
}
protected void btnPost_Click(object sender, EventArgs e)
{
if (files.Count > 0)
{
if (!Directory.Exists(MapPath("../bodyissue/temp")))
Directory.CreateDirectory(MapPath("../bodyissue/temp"));
foreach (FileUpload fup in files)
{
if (fup.HasFile)
fup.SaveAs(MapPath("../bodyissue/temp") + "/" + fup.FileName);//无法访问已关闭的文件
}
Page.ClientScript.RegisterClientScriptBlock(typeof(string), "", @"<script>alert('上传成功!')</script>");
}
}
}