<%@ WebHandler Language="C#" Class="Load" debug="true"%> using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Configuration; using System.Data; using eMIS; using eMIS.Data; using System.Text; using System.IO; using Newtonsoft.Json; public class Load : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); StringBuilder sbstr = new StringBuilder(); string connectionString = ConfigurationManager.AppSettings["emisdb0"].ToString(); eDbManager manager = new eDbManager(connectionString); eDbOperator dbo = manager.CreateDbOperator(); int count = context.Request.Files.Count; string TransID = context.Request.Form["id"]; for (int i = 0; i < count; i++) { int l = context.Request.Files[i].ContentLength; byte[] buffer = new byte[l]; Stream s = context.Request.Files[i].InputStream; System.Drawing.Bitmap image = new System.Drawing.Bitmap(s); string imgname = TransID+"-"+i.ToString()+ ".jpg."+Guid.NewGuid().ToString("N"); string path = "~/App_Files/webapp/" + DateTime.Now.ToString("yyyyMMdd") + "/"; if (!Directory.Exists(HttpContext.Current.Server.MapPath(path))) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(path)); } image.Save(context.Server.MapPath(path + imgname)); sbstr.Append("/App_Files/webapp/" + DateTime.Now.ToString("yyyyMMdd") + "/" + imgname); sbstr.Append("|"); } string sbstrfinal = sbstr.ToString(); if (sbstrfinal.Length > 0) { sbstrfinal = sbstrfinal.Substring(0, sbstrfinal.Length - 1); } context.Response.ContentType = "application/html"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; context.Response.Write(sbstrfinal.ToString()); context.Response.End(); } public bool IsReusable { get { return false; } } }