protected void LinkButton1_Click(object sender, EventArgs e) { RadUploadContext upContext = RadUploadContext.Current; string dir = Server.MapPath("~/App_Uploads_Img/"); if (RadUpload1.UploadedFiles.Count > 0) { foreach (Telerik.Web.UI.UploadedFile file in RadUpload1.UploadedFiles) { if ((DropDownList1I.SelectedIndex == 0) && (tbDirectoryImage.Text.Length == 0)) { Session["cat"] = null; Session["Files"] = null; TabPanel3.Focus(); } else if ((DropDownList1I.SelectedIndex == 0) && (tbDirectoryImage.Text.Length > 0)) { string width = ResizeWidth; string height = ResizeHeight; string suffix = ResizeSuffix; Directory.CreateDirectory(dir + tbDirectoryImage.Text); string name = file.GetName(); if (ResizeImage == true) { string path = tbDirectoryImage.Text + "/"; string physicalpath = Server.MapPath("~/App_Uploads_Img/" + tbDirectoryImage.Text + "/"); // Save temporary file, we'll use this for our resizing then delete it after if (!File.Exists(physicalpath + name)) { file.SaveAs(physicalpath + name, true); } // Begin resize function resize(name, path, physicalpath, width, height, suffix); } else { string physicalpath = Server.MapPath("~/App_Uploads_Img/" + tbDirectoryImage.Text + "/"); file.SaveAs(physicalpath + name, true); } Session["cat"] = tbDirectoryImage.Text; string sFileName = file.GetName().ToLower(); string na = sFileName.Substring(0, sFileName.LastIndexOf(".")); string format = sFileName.Substring(na.Length); if (suffix != "") { suffix = "_" + suffix; } sImageName = na + suffix + format; sImageName = sImageName.Replace(" ", "_"); Session["Files"] = sImageName; } else if ((DropDownList1I.SelectedIndex != 0) && (tbDirectoryImage.Text.Length > 0)) { string width = ResizeWidth; string height = ResizeHeight; string suffix = ResizeSuffix; Directory.CreateDirectory(dir + DropDownList1I.SelectedItem.Text + "/" + tbDirectoryImage.Text); string name = file.GetName(); if (ResizeImage == true) { string path = DropDownList1I.SelectedItem.Text + "/" + tbDirectoryImage.Text + "/"; string physicalpath = Server.MapPath("~/App_Uploads_Img/" + DropDownList1I.SelectedItem.Text + "/" + tbDirectoryImage.Text + "/"); // Save temporary file, we'll use this for our resizing then delete it after if (!File.Exists(physicalpath + name)) { file.SaveAs(physicalpath + name, true); } // Begin resize function resize(name, path, physicalpath, width, height, suffix); } else { string physicalpath = Server.MapPath("~/App_Uploads_Img/" + DropDownList1I.SelectedItem.Text + "/" + tbDirectoryImage.Text + "/"); if (!File.Exists(physicalpath + name)) { file.SaveAs(physicalpath + name, true); } } Session["cat"] = (DropDownList1I.SelectedItem.Text + "/" + tbDirectoryImage.Text); string sFileName = file.GetName().ToLower(); string na = sFileName.Substring(0, sFileName.LastIndexOf(".")); string format = sFileName.Substring(na.Length); if (suffix != "") { suffix = "_" + suffix; } sImageName = na + suffix + format; sImageName = sImageName.Replace(" ", "_"); Session["Files"] = sImageName; } else if ((DropDownList1I.SelectedIndex > 0) && (tbDirectoryImage.Text.Length == 0)) { string width = ResizeWidth; string height = ResizeHeight; string suffix = ResizeSuffix; string name = file.GetName(); if (ResizeImage == true) { string path = DropDownList1I.SelectedItem.Text + "/"; string physicalpath = Server.MapPath("~/App_Uploads_Img/" + DropDownList1I.SelectedItem.Text + "/"); // Save temporary file, we'll use this for our resizing then delete it after if (!File.Exists(physicalpath + name)) { file.SaveAs(physicalpath + name, true); } // Begin resize function resize(name, path, physicalpath, width, height, suffix); } else { string physicalpath = Server.MapPath("~/App_Uploads_Img/" + DropDownList1I.SelectedItem.Text + "/"); if (!File.Exists(physicalpath + name)) { file.SaveAs(physicalpath + name, true); } } // Assign a session variable so we can auto-select it from the dropdown Session["cat"] = DropDownList1I.SelectedItem.Text; string sFileName = name.ToLower(); string na = sFileName.Substring(0, sFileName.LastIndexOf(".")); string format = sFileName.Substring(na.Length); if (suffix != "") { suffix = "_" + suffix; } sImageName = na + suffix + format; sImageName = sImageName.Replace(" ", "_"); Session["Files"] = sImageName; } } GC.Collect(); } getfolders(ref al, Server.MapPath("~/App_Uploads_Img/")); getallfolders(ref al2, Server.MapPath("~/App_Uploads_Img/")); if ((Session["cat"] != null) && (Session["Files"] != null)) { ddCatImage.SelectedValue = Session["cat"].ToString().Replace("\\", "/"); getfiles(Server.MapPath("~/App_Uploads_Img/") + ddCatImage.SelectedItem.Value); string myfiles = Session["Files"].ToString(); try { ddFilesImage.SelectedValue = myfiles.ToLower(); } catch (Exception ex) { } showimage(ddCatImage.SelectedValue, ddFilesImage.SelectedValue); } tbDirectoryImage.Text = ""; //UpdatePanel1Image.Update(); //UpdatePanel2Image.Update(); }