protected void ajaxFileUpload_OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        if(e.ContentType.Contains("jpg") || e.ContentType.Contains("gif")
            || e.ContentType.Contains("png") || e.ContentType.Contains("jpeg")) {
            Session["fileContentType_" + e.FileId] = e.ContentType;
            Session["fileContents_" + e.FileId] = e.GetContents();
        }

        // Set PostedUrl to preview the uploaded file.
        e.PostedUrl = string.Format("?preview=1&fileId={0}", e.FileId);
    }
        protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            try
            {
                Account account = new Account("dlyvxs7of", "634626974285569", "FtB_0jhcmFypFS7QTwCBKcPRGzE");

                Cloudinary cloudinary = new Cloudinary(account);
                ImageUploadParams uploadParams = new ImageUploadParams()
                    {
                        File = new FileDescription("file", new MemoryStream(e.GetContents()))
                    };

                ImageUploadResult uploadResult = cloudinary.Upload(uploadParams);

                HEWDataContext context = new HEWDataContext();
                context.ProjectsImages.InsertOnSubmit(new ProjectsImage
                    {ImgPublicID = uploadResult.PublicId, ProjectID = int.Parse(Request.QueryString["ProjectID"])});
                context.SubmitChanges();
            }
            catch (Exception)
            {
            }
        }
        protected void saveImage(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            string tempPath = System.IO.Path.GetTempPath();
            System.Drawing.Image img = new GUIHelper().byteArrayToImage(e.GetContents());

            if (Session["fileContentType_"] == null)
            {
                Session.Add(("fileContentType_"), e.ContentType);
            }
            Session["fileContentType_"] = e.ContentType;

            if (Session["fileContents_"] == null)
            {
                Session.Add("fileContents_", e.GetContents());
            }
            Session["fileContents_"] = e.GetContents();

            string relativePath = Page.AppRelativeVirtualPath;
            relativePath = relativePath.Replace("~", "");
            e.PostedUrl = String.Format("/HRM" + relativePath + "?preview=1");
        }