hjkhhndndndnd,trt
bnmbertsu,yu,yu,fffffffy,ltdfg
/
home4
/
gofvotmy
/
www
/
punjabcollegeoflaw
/
Application
/
admin
/
Upload FileeE
HOME
<%@ WebHandler Language="C#" Class="MasterGallery" %> using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing; using System.Drawing.Drawing2D; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Reflection; using System.IO; using System.Web.SessionState; public class MasterGallery : IHttpHandler, IRequiresSessionState { upload.GalleryDetailPrp objprp = new upload.GalleryDetailPrp(); upload.GalleryDetail obj = new upload.GalleryDetail(); public void ProcessRequest (HttpContext context) { string filename = string.Empty; string fileobj = string.Empty; string str_image = ""; context.Response.ContentType = "text/plain"; try { string dirFullPath = HttpContext.Current.Server.MapPath(global.upload); foreach (string s in context.Request.Files) { HttpPostedFile file = context.Request.Files[s]; string fileName = file.FileName; string fileExtension = file.FileName.Split('.')[1]; if (context.Request["action"].ToString() == "0") { string activationKey = Guid.NewGuid().ToString(); str_image = activationKey +"."+fileExtension; } else { str_image = "Master_" + context.Request["action"].ToString() + fileExtension; } if (!string.IsNullOrEmpty(fileName)) { string filePath = global.uploadurl + str_image; System.Drawing.Bitmap originalBMP = new System.Drawing.Bitmap(file.InputStream); int origWidth = originalBMP.Width; int origHeight = originalBMP.Height; if (origWidth > 350 || origHeight > 233) { System.Drawing.Image objImage = ResizeMyImage(originalBMP, origWidth, origHeight, 345, 220); objImage.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg); } else { file.SaveAs(filePath); } context.Response.Write(str_image); } else { context.Response.Write("Error"); } } } catch (Exception ac) { } } public bool IsReusable { get { return false; } } public static System.Drawing.Image ResizeMyImage(System.Drawing.Image originalBMP, int origWidth, int origHeight, int newWidth, int newHeight) { float sngRatio = (float)origWidth / origHeight; Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight); Graphics oGraphics = Graphics.FromImage(newBMP); oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic; oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight); oGraphics.Dispose(); return newBMP; } }