因为工作需求需要,所以闲来无聊随手写了一个多图片上传。不多说直接上源码!!
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="uploadScrollImg.aspx.cs" Inherits="HighWeb.uploadScrollImg" %>图片批量上传
using System;using System.Collections.Generic;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.IO;namespace HighWeb{ public partial class uploadScrollImg : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { UploadMsg = "图片上传组件已经就绪"; loadSucces = "[]"; if (!IsPostBack) { if (Request.Files.Count > 0) { UploadMsg = "图片"; loadSucces = "["; bool f = false; foreach (string k in Request.Files.AllKeys) { if (!string.IsNullOrEmpty(Request.Files[k].FileName)) { string fileName = string.Format("{0}{1}", Guid.NewGuid().ToString().Replace("-", ""), Path.GetExtension(Request.Files[k].FileName)); Request.Files[k].SaveAs(string.Format("{0}{1}", Server.MapPath("~/uploadResurce/"), fileName)); if (f) { loadSucces += ","; UploadMsg += ","; } loadSucces += "{fn:'" + k + "',ph:'/uploadResurce/" + fileName + "'}"; UploadMsg += Request.Files[k].FileName; f = true; } } loadSucces += "]"; UploadMsg += "已经上传成功 !"; } } } protected string loadSucces { private set; get; } protected string UploadMsg { private set; get; } }}