protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { byte[] image = e.GetContents(); MembershipUser currentUser = Membership.GetUser(); if (currentUser != null) { currentUserId = (Guid)currentUser.ProviderUserKey; string connectionString = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString; string updateSql = "UPDATE UserProfiles SET BackgroundPicture = @BackgroundPicture WHERE UserId = @UserId"; try { using (SqlConnection myConnection = new SqlConnection(connectionString)) { myConnection.Open(); SqlCommand myCommand = new SqlCommand(updateSql, myConnection); myCommand.Parameters.AddWithValue("@UserId", currentUserId); myCommand.Parameters.AddWithValue("@BackgroundPicture", image); myCommand.ExecuteNonQuery(); myConnection.Close(); } } catch { } } this.DataBind(); e.DeleteTemporaryData(); }
protected void afuUpload_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success) { return; } PendingFlight pf = new PendingFlight() { User = Page.User.Identity.Name }; string szOriginal = pf.FlightData = System.Text.Encoding.UTF8.GetString(e.GetContents()); using (FlightData fd = new FlightData()) { fd.AutoFill(pf, (AutoFillOptions)Session[SessionKeyOpt]); pf.FlightData = string.Empty; LogbookEntry leEmpty = new PendingFlight() { User = Page.User.Identity.Name, FlightData = string.Empty }; if (!pf.IsEqualTo(leEmpty)) { pf.TailNumDisplay = fd.TailNumber ?? string.Empty; pf.FlightData = szOriginal; pf.Commit(); } } }
protected void AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { // User can save file to File System, database or in session state if(file.ContentType.Contains("jpg") || file.ContentType.Contains("gif") || file.ContentType.Contains("png") || file.ContentType.Contains("jpeg")) { // Limit preview file for file equal or under 4MB only, otherwise when GetContents invoked // System.OutOfMemoryException will thrown if file is too big to be read. if(file.FileSize <= 1024 * 1024 * 4) { Session["fileContentType_" + file.FileId] = file.ContentType; Session["fileContents_" + file.FileId] = file.GetContents(); // Set PostedUrl to preview the uploaded file. file.PostedUrl = string.Format("?preview=1&fileId={0}", file.FileId); } else { file.PostedUrl = "fileTooBig.gif"; } // Since we never call the SaveAs method(), we need to delete the temporary fileß file.DeleteTemporaryData(); } // In a real app, you would call SaveAs() to save the uploaded file somewhere // AjaxFileUpload1.SaveAs(MapPath("~/App_Data/" + file.FileName), true); }
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success) { return; } using (FlightData fd = new FlightData()) { if (fd.ParseFlightData(System.Text.Encoding.UTF8.GetString(e.GetContents()))) { if (fd.HasLatLongInfo) { Coordinates.AddRange(fd.GetTrajectory()); HasTime = HasTime && fd.HasDateTime; HasAlt = HasAlt && fd.HasAltitude; HasSpeed = HasSpeed && fd.HasSpeed; } } else { lblErr.Text = fd.ErrorString; } } e.DeleteTemporaryData(); }
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 AjaxFileUpload1_OnUploadComplete(object sender, AjaxFileUploadEventArgs file) { // User can save file to File System, database or in session state if (file.ContentType.Contains("jpg") || file.ContentType.Contains("gif") || file.ContentType.Contains("png") || file.ContentType.Contains("jpeg")) { Session["fileContentType_" + file.FileId] = file.ContentType; Session["fileContents_" + file.FileId] = file.GetContents(); } // Set PostedUrl to preview the uploaded file. file.PostedUrl = string.Format("?preview=1&fileId={0}", file.FileId); }
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success) { return; } TimeZoneInfo tz = (TimeZoneInfo)Session[SessionKeyTZ]; TelemetryMatchResult tmr = new TelemetryMatchResult() { TelemetryFileName = e.FileName }; if (tz != null) { tmr.TimeZoneOffset = tz.BaseUtcOffset.TotalHours; } DateTime? dtFallback = null; Regex rDate = new Regex("^(?:19|20)\\d{2}[. _-]?[01]?\\d[. _-]?[012]?\\d", RegexOptions.Compiled); MatchCollection mc = rDate.Matches(e.FileName); if (mc != null && mc.Count > 0 && mc[0].Groups.Count > 0) { DateTime dt; if (DateTime.TryParse(mc[0].Groups[0].Value, out dt)) { dtFallback = dt; tmr.TimeZoneOffset = 0; // do it all in local time. } } tmr.MatchToFlight(System.Text.Encoding.UTF8.GetString(e.GetContents()), Page.User.Identity.Name, dtFallback); Results.Add(tmr); e.DeleteTemporaryData(); }
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success) { lblFileRequired.Text = Resources.LogbookEntry.errImportInvalidCSVFile; SetWizardStep(wsUpload); return; } Session[szSessFile] = e.GetContents(); e.DeleteTemporaryData(); // Now we wait for the force refresh }
protected void buzon_HtmlEditorExtender_ImageUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { MemoryStream datosImagen = new MemoryStream(e.GetContents()); System.Drawing.Image imagen = System.Drawing.Image.FromStream(datosImagen); if (imagen.Width > imagen.Height) { if (imagen.Width > 250) { int alturaImagen = 250 * imagen.Height / imagen.Width; imagen = new Bitmap(imagen, 250, alturaImagen); } } else { if (imagen.Height > 250) { int anchuraImagen = 250 * imagen.Width / imagen.Height; imagen = new Bitmap(imagen, anchuraImagen, 250); } } ImageConverter conversor = new ImageConverter(); byte[] datosImagenRedimensionada = (byte[])conversor.ConvertTo(imagen, typeof(byte[])); 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] = datosImagenRedimensionada; } e.PostedUrl = string.Format("?preview=1&fileId={0}", e.FileId); }
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (e.State != AjaxControlToolkit.AjaxFileUploadState.Success) { return; } string szKey = FileObjectSessionKey(e.FileId); PendingIDs.Add(szKey); Session[szKey] = new MFBPendingImage(new MFBPostedFile(e.FileName, e.ContentType, e.FileSize, e.GetContents(), e.FileId), szKey); e.DeleteTemporaryData(); RefreshPreviewList(); if (Mode == UploadMode.Legacy) { Mode = UploadMode.Ajax; } if (UploadComplete != null) { UploadComplete(this, e); } }
protected void ajaxUpload1_OnUploadComplete(object sender, 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); // Generate file path string filePath = "~/Images/" + e.FileName; var ajaxFileUpload = htmlEditorExtender2.AjaxFileUpload; //ajaxFileUpload.AllowedFileTypes = "jpg,jpeg,gif,png"; // Save upload file to the file system ajaxFileUpload.SaveAs(MapPath(filePath)); // Update client with saved image path e.PostedUrl = Page.ResolveUrl(filePath); }
protected void fuProfilePhoto_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { imgProfilePhoto.ImageUrl = "data:" + e.ContentType + ";base64," + Convert.ToBase64String(e.GetContents()); }
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { byte[] image = e.GetContents(); }