Sindbad~EG File Manager

Current Path : C:/Inetpub/vhosts/yuksekkariyer.com/httpdocs/admin/
Upload File :
Current File : C:/Inetpub/vhosts/yuksekkariyer.com/httpdocs/admin/UploadUrun.ashx

<%@ WebHandler Language="C#" Class="UploadUrun" %>

using System;
using System.Data.OleDb;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.IO;
using System.Data;
using ImageResizer;

public class UploadUrun : IHttpHandler {
    string silinicekresim;
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Expires = -1;
        try
        {
            if (Genel.Urunid != 0)
            {
                HttpPostedFile postedFile = context.Request.Files["Filedata"];
                string savepath = "";
                string tempPath = "";
                tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
                savepath = context.Server.MapPath(tempPath);
                int gelendeger = Genel.Urunid;
                string filename = postedFile.FileName;
                string extension = Path.GetExtension(postedFile.FileName).ToLower();
                string eklemeveri = "";
                eklemeveri = "_urun_" + DateTime.Now.ToString("MMddyyhhmmss") + filename;
               // string imagesPath = savepath + "\\urunler\\" + "_urun_" + DateTime.Now.ToString("MMddyyhhmmss") + filename;
                if (!Directory.Exists(savepath))
                    Directory.CreateDirectory(savepath);
                string deger = savepath + @"\" + Path.GetFileNameWithoutExtension(eklemeveri) + ".jpg";
                postedFile.SaveAs(deger);

                //Daha sonra eklentimin metodlarını kullanarak resmimin boyutlandırma işlemini yaptım.
                ResizeSettings resizeCropSettings1 = new ResizeSettings("width=1080&height=1080&mode=pad");
                string fileName = Path.Combine(savepath, eklemeveri);
                fileName = ImageBuilder.Current.Build(savepath + "\\" + Path.GetFileNameWithoutExtension(eklemeveri) + ".jpg", string.Concat(savepath + "\\", Path.GetFileNameWithoutExtension(fileName)), resizeCropSettings1, false, true);//ŞU SATIRDAN SONRA İKİNCİ UZANTI EKLİYO yani jpg.jpg yapıyo bunu nasıl engellerim


                Bitmap imgOutput = new Bitmap(deger);// Büyük Boyutlu resmimizin Alındı Dosya Yeri  dosyanın önceki boyutu : 560 kb 
                Graphics outputGraphics = Graphics.FromImage(imgOutput);

                EncoderParameters myEncoderParameters = new EncoderParameters(3);
                myEncoderParameters.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100L); // buradaki  45L yazan yer resmin kalitesine doğru orantılı olarak çalışıyor 100 yaparsanız en iyi şekilde resmi çıkarıyor ben boyuttan kısmak istediğim için 45 yaptım 
                myEncoderParameters.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.ScanMethod, (int)EncoderValue.ScanMethodInterlaced);
                myEncoderParameters.Param[2] = new EncoderParameter(System.Drawing.Imaging.Encoder.RenderMethod, (int)EncoderValue.RenderProgressive);

                ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
                ImageCodecInfo ici = null;
                foreach (ImageCodecInfo codec in codecs)
                {
                    if (codec.MimeType == "image/jpeg")
                        ici = codec;
                }
                imgOutput.Save(savepath + "\\urunler\\" + Path.GetFileNameWithoutExtension(eklemeveri) + ".jpg", ici, myEncoderParameters);//buraada ise resminizin nereye kaydedilmesini istiyorsanız onu seçiyorsunuz bu kod blogunu çalıştırdıktan sonra resimim kalitesi düşmüş olarak ( boyutu kb ) geri geldi ve sonraki halide 37 kb di 
                if (File.Exists(savepath + "\\" + eklemeveri))
                {
                    outputGraphics.Dispose();
                    imgOutput.Dispose();
                    File.Delete(savepath + "\\" + eklemeveri);
                }

                context.Response.Write(tempPath + "/" + Path.GetFileNameWithoutExtension(eklemeveri) + ".jpg");

                context.Response.Write(tempPath + "/" + filename);
                context.Response.StatusCode = 200;
                
       
                int ID;
                string query2 = "Select @@Identity";
                using (OleDbConnection vt = new baglanti().baglan())
                {
                    vt.Open();
                    OleDbCommand cmd = new OleDbCommand("INSERT INTO urunresimleri (resim,UrunID) VALUES ('" + Path.GetFileNameWithoutExtension(eklemeveri) + ".jpg" + "','" + Genel.Urunid + "')", vt);
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = query2;
                    ID = (int)cmd.ExecuteScalar();
                    vt.Close();
                }
              
            }
        }
        catch (Exception ex)
        {
            context.Response.Write("Error: " + ex.Message);
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists