private void View_FileUploadClick(object sender, FileUploadEventArgs e) { var user = this.userService.FindById(e.UserId); var uploader = this.imageUploadService.GetUploader(); var uploadParams = new ImageUploadParams() { File = new FileDescription(e.FilePath), Transformation = new Transformation().Gravity("face") }; var uploadResult = uploader.Upload(uploadParams); if (uploadResult.Error == null) { string url = uploadResult.SecureUri.OriginalString; user.ImageUrl = url; try { this.userService.Save(); } catch (Exception) { this.View.Model.IsSuccess = false; this.View.Model.ErrorMessage = "Cannot apply image for this user."; return; } this.View.Model.IsSuccess = true; } else { this.View.Model.IsSuccess = false; this.View.Model.ErrorMessage = uploadResult.Error.Message; } }
private void SdkWrapper_FileUploadUpdated(object sender, FileUploadEventArgs e) { if (e.FileDescriptor.Id == uploadFileDescriptorIdInProgress) { if (!e.InProgress) { FileUploadModel fileUploadModel = GetFileUploadByFileDescriptorId(uploadFileDescriptorIdInProgress); if (e.Completed) { // Send message Conversation conversation = Helper.SdkWrapper.GetConversationByPeerIdFromCache(fileUploadModel.PeerId); Rainbow.Model.Message message = fileUploadModel.RbMessage; Helper.SdkWrapper.SendMessage(conversation, ref message); // Remove this file from dictionaries RemoveFileByFullPath(fileUploadModel.FileFullPath); // The stream is closed in this method } else { UploadCannnotBeDone(fileUploadModel); } // The upload is finished uploadFileDescriptorIdInProgress = null; // Use upload pool UseUploadPool(); } } }
public void ImageUploader1_FileUploaded(object sender, FileUploadEventArgs e) { //Save file and thumbnail string physGalleryPath = Server.MapPath(galleryPath); string sourceFileName = e.SourceFile.GetSafeFileName(physGalleryPath); e.SourceFile.Save(System.IO.Path.Combine(physGalleryPath, sourceFileName)); string physThumbnailsPath = Server.MapPath(galleryPath + "Thumbnails/"); string thumbnailFileName = e.Thumbnails[1].GetSafeFileName(physThumbnailsPath); e.Thumbnails[1].Save(System.IO.Path.Combine(physThumbnailsPath, thumbnailFileName)); //Save file info. lock (Application) { XmlDocument descriptions = new XmlDocument(); descriptions.Load(Server.MapPath(galleryPath + "Descriptions.xml")); XmlElement file = descriptions.CreateElement("file"); file.SetAttribute("name", sourceFileName); file.SetAttribute("thumbName", thumbnailFileName); file.SetAttribute("width", Convert.ToString(e.SourceFile.Width)); file.SetAttribute("height", Convert.ToString(e.SourceFile.Height)); file.SetAttribute("description", e.Description); file.SetAttribute("handlerUrl", Request.Url.PathAndQuery); descriptions.DocumentElement.AppendChild(file); descriptions.Save(Server.MapPath(galleryPath + "Descriptions.xml")); } }
void fileUpload_FileUploadCompleted(object sender, FileUploadEventArgs e) { this.Invoke(new UpdateUIDelegate(delegate(object obj) { FileUploadEventArgs arg = e as FileUploadEventArgs; this.tabPage3.Controls.Remove(e.FileUploadControl); if (this.tabPage3.Controls.Count == 0) { this.tabPage3.Parent.Controls.Remove(this.tabPage3); } UploadStatus status = arg.Status; string fileName = arg.FileName; displayUploadStatusMessage(status, fileName); }), e); this.uploadTasks.Remove(e.FileUploadControl.FtpUpload); if (e.Status == UploadStatus.Succeed) { operatorServiceAgent.SendFile(e.FileName, this.chat.ChatId, "complete"); } }
/// <summary> /// Evento que se lanza al guardar los archivos en el servidor /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void muSubirImagenesOrdenEstimacion_OnFileUpload(object sender, FileUploadEventArgs e) { //1. Obtener el ID del movimiento y el concepto int iID = Convert.ToInt32(Cookies.GetCookie("cookieEditarOrdenEstimacion").Value); string strConcepto = Cookies.GetCookie("cookieConceptoOrdenEstimacion").Value; string strDireccion = Server.MapPath(" ") + "\\imagenesOrdenEstimacion\\" + iID + "\\" + strConcepto; //2. Validar si existe el directorio donde se guardaran las imagenes if (Directory.Exists(strDireccion)) { e.PostedFile.SaveAs(strDireccion + "\\" + e.FileName); } else { Directory.CreateDirectory(strDireccion); e.PostedFile.SaveAs(strDireccion + "\\" + e.FileName); } //3. Realizar el objeto e insertar en la base de datos ImagenOrdenEstimacionD oImagenOrdenEstimacionD = new ImagenOrdenEstimacionD(); oImagenOrdenEstimacionD.MovID = iID; oImagenOrdenEstimacionD.Concepto = strConcepto; oImagenOrdenEstimacionD.Nombre = e.FileName; oImagenOrdenEstimacionD.Direccion = "\\imagenesOrdenEstimacion\\" + iID + "\\" + strConcepto + "\\" + e.FileName; //Traemos el usuario que realiza el movimiento Usuario oUsuario = (Usuario)Session["Usuario"]; oImagenOrdenEstimacionD.Usuario = oUsuario.ID; oImagenOrdenEstimacionD.FechaAlta = DateTime.Now; ImagenOrdenEstimacionBusiness.Insertar(oImagenOrdenEstimacionD); }
protected void UploadImage(object sender, EventArgs e) { var selectedFile = this.file.PostedFile; if (!selectedFile.ContentType.Contains("image")) { this.FileError.InnerText = "Invalid file format"; return; } this.FileError.InnerText = ""; if (selectedFile != null && selectedFile.ContentLength <= Utils.Constants.ImageUploadMaxSize) { var filePath = Server.MapPath($"~/Uploaded_Files/{this.file.FileName}"); selectedFile.SaveAs(filePath); var id = Context.User.Identity.GetUserId(); var ev = new FileUploadEventArgs(id, filePath, this.file.FileName); this.FileUploadClick?.Invoke(sender, ev); if (this.Model.IsSuccess) { this.Message.ShowSuccess("Image uploaded."); } else { this.Message.ShowError(this.Model.ErrorMessage); } File.Delete(filePath); } else { this.FileError.InnerText = "File must be less tha 500Kb."; } }
protected void muSubirImagenesCliente_OnFileUpload(object sender, FileUploadEventArgs e) { X.Msg.Notify("El archivo esta subiendose", "Nombre: " + e.FileName).Show(); }
protected void MultiUpload1_FileUpload(object sender, FileUploadEventArgs e) { X.Msg.Notify("File is uploaded", "Name: " + e.FileName).Show(); }
// declare the event method protected virtual void OnFileUploaded( FileUploadEventArgs e) { // fire the delegate FileUploaded(this, e); }
/// <summary> /// 每次与客户端建立连接准备上传文件时调用此方法。注意:一个文件的上传过程可能会多次调用此方法。 /// </summary> public virtual void BeginUpload(FileUploadEventArgs e) { }
internal void OnFileUploadUpdated(object sender, FileUploadEventArgs args) { FileUploadUpdated.Raise(sender, args); }
public OpenFileDialogEventArgs(FileUploadEventArgs fileUploadEventArgs) { _fileUploadEventArgs = fileUploadEventArgs; }
public bool UploadFiles(Panel container) { bool res = false; int counter = 0; uploadedFiles.Clear(); //loop through FileUploads controls in panel foreach (Control upload in container.Controls) { if (upload is System.Web.UI.WebControls.FileUpload) { UploadFile((System.Web.UI.WebControls.FileUpload)upload, counter); counter++; res = true; } } if (this.AfterUpload != null) { var args = new FileUploadEventArgs(this.UploadedFiles, "", res); this.AfterUpload(this, args); } return res; }