文件上传组件,所需js文件和图片在百度网盘对应的文件夹下
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SWFUpload_Demo.aspx.cs" Inherits="BookShop.Web.Test.SWFUpload_Demo" %>
using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Web;namespace BookShopManager.Web.Ashx{ ////// FileUpload 的摘要说明 /// public class FileUpload : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpPostedFile file = context.Request.Files["Filedata"]; if (file != null) { string fileName = Path.GetFileName(file.FileName); string fileExt = Path.GetExtension(fileName); if (fileExt == ".jpg") { string dir = "/FileUpload/" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "/"; if (!Directory.Exists(context.Request.MapPath(dir))) { Directory.CreateDirectory(context.Request.MapPath(dir)); } string newFileName = Guid.NewGuid().ToString(); string fullDir = dir + newFileName + fileExt; file.SaveAs(context.Request.MapPath(fullDir)); context.Response.Write(fullDir); } } } public bool IsReusable { get { return false; } } }}