Skip to content
Loading
  
  • "btnViewGallery" runat="server" Text="View Gallery" OnClick="btnViewGallery_Click" /> 
      
  •   
  •   
  •   
  • Code :
    1. #region Ajax Upload File  
    2. protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)  
    3. {  
    4. string filePath = string.Empty;  
    5. try  
    6. {  
    7. string strID = Session["selectedid"].ToString();  
    8. int compid = Convert.ToInt32(Session["COMPID"]);  
    9. filePath = (Server.MapPath("~/fileupload/gallery/") + Guid.NewGuid() + System.IO.Path.GetFileName(e.FileName));  
    10. AjaxFileUpload1.SaveAs(filePath);  
    11. string strFile = filePath.Substring(filePath.LastIndexOf("\\"));  
    12. string strFileName = strFile.Remove(0, 1);  
    13. string strFilePath = "~/fileupload/gallery/" + strFileName;  
    14. string input = Server.MapPath("fileupload/gallery/") + strFileName;  
    15. string thumb = Server.MapPath("fileupload/gallery/thumb/") + strFileName;  
    16. string output = Server.MapPath("fileupload/gallery/display/") + strFileName;  
    17. // Load image.  
    18. System.Drawing.Image image = System.Drawing.Image.FromFile(input);  
    19. Size thumbnailSize = GetImageSize(image, 110);  
    20. System.Drawing.Image thumbnail = resizeImage(image, thumbnailSize);  
    21. thumbnail.Save(thumb);  
    22. Size displaySize = GetImageSize(image, 640);  
    23. System.Drawing.Image display = resizeImage(image, displaySize);  
    24. display.Save(output);  
    25. // Compute thumbnail size, Get thumbnail & Save thumbnail.  
    26. /*  
    27. Size thumbnailSize = GetImageSize(image,110);  
    28. System.Drawing.Image thumbnail = image.GetThumbnailImage(thumbnailSize.Width,  
    29. thumbnailSize.Height, null, IntPtr.Zero);  
    30. thumbnail.Save(thumb);  
    31. }  
    32. catch (Exception ex)  
    33. {  
    34. Response.Write(ex.Message.ToString());  
    35. }  
    36. }  
    37. #endregion