protected void FileImageAlbum_FileUploaded(object sender, FileUploadedEventArgs e) { var FileImageAlbum = (RadAsyncUpload)sender; var Parent = FileImageAlbum.NamingContainer; var ProductID = ((HiddenField)Parent.FindControl("hdnProductID")).Value; var RadListView1 = (RadListView)Parent.FindControl("RadListView1"); var RadListView2 = (RadListView)Parent.FindControl("RadListView2"); string targetFolder = "~/res/product/album/"; string newName = Guid.NewGuid().GetHashCode().ToString("X") + e.File.GetExtension(); e.File.SaveAs(Server.MapPath(targetFolder + newName)); ResizeCropImage.ResizeByCondition(targetFolder + newName, 800, 800); ResizeCropImage.CreateThumbNailByCondition("~/res/product/album/", "~/res/product/album/thumbs/", newName, 120, 120); if (string.IsNullOrEmpty(ProductID)) { TempImage.Rows.Add(new object[] { newName }); RadListView2.DataSource = TempImage; RadListView2.DataBind(); } else { var oProductImage = new ProductImage(); oProductImage.ProductImageInsert(newName, "", "", "", "", "", ProductID, "True", ""); RadListView1.Rebind(); } }
protected void AsyncUpload1_FileUploaded2(object sender, FileUploadedEventArgs e) { try { string urlImage = string.Empty; imgAlumno.Dispose(); string path = Server.MapPath("~/Images/Temp/"); string fullpath = string.Empty; //if (txtMatricula.Text == string.Empty) //{ fullpath = path + "tmpFotoAlumno_" + Context.User.Identity.Name.ToString() + e.File.GetExtension(); urlImage = "tmpFotoAlumno_" + Context.User.Identity.Name.ToString() + e.File.GetExtension(); //} //else //{ // fullpath = path + txtMatricula.Text.ToString() + e.File.GetExtension(); // urlImage = txtMatricula.Text.ToString() + e.File.GetExtension(); //} e.File.SaveAs(fullpath, true); imgAlumno.ImageUrl = "../Images/Temp/" + urlImage; ViewState["banEntra"] = "1"; ScriptManager.RegisterStartupScript(this, this.GetType(), "clearUpload", String.Format("$find('{0}').deleteAllFileInputs()", AsyncUpload1.ClientID), true); } catch (Exception oExeption) { } }
private void FileService_OnFileUploaded(object sender, FileUploadedEventArgs e) { if (e.MimeType == AllowedMimeTypes.Text.Xml) { var products = GetProductsFromXml(e.File); if (products != null) { foreach (var product in products) { var currentProduct = GetByHandle(product.Handle); if (currentProduct != null) { if (!currentProduct.Equals(product)) { Update(product); } } else { Insert(product); } } } } }
public void aupPresentation_FileUploaded(object sender, FileUploadedEventArgs e) { Session["FolderType"] = "PRESENTATION"; telerikAsyncUploadResult result = e.UploadResult as telerikAsyncUploadResult; if (result != null) { if (result.DocumentID > 0) { WebinarResource objWebinarResource = new WebinarResource(); objWebinarResource.WebinarID = Convert.ToInt32(hWebinarID.Value); objWebinarResource.DocID = result.DocumentID; objWebinarResource.ResourceType = "Presentation"; objWebinarResource.ResourceTitle = e.File.FileName; objWebinarResource.ResourceValue = ""; objWebinarResource.IsBriefcase = false; //chkAddtoBC.Checked; if (objWebinarDA.InsertWebinarResources(objWebinarResource) == 0) { DocAccess objDocAccess = new DocAccess(); objDocAccess.removeDocumentFromRepositary(result.DocumentID,Convert.ToInt32(Session["ClientID"]),"WebinarDocs"); } //if (chkAddtoBC.Checked && !chkConfig8.Checked) //{ // objWebinarDA.SaveWebinarAudience(Convert.ToInt32(hWebinarID.Value), "Content", (Convert.ToInt32(ClientConfigMaster.Audi_Component_Content)).ToString()); // chkConfig8.Checked = true; //} // popResource(); // popPresentation(); } } }
protected void Uploader1_FileUploaded(object sender, FileUploadedEventArgs e) { UploadedFile uploadedFile = e.UploadedFile; ThumbnailsGallery gallery = new ThumbnailsGallery(); // Is it new upload session? if (uploadedFile.Package.PackageIndex == 0 && uploadedFile.Index == 0) { // Remove previously uploaded files gallery.Empty(); } // Save thumbnail ConvertedFile thumbnailFile = uploadedFile.ConvertedFiles[0]; if (thumbnailFile != null) { string thumbnailName = Utils.GetSafeFileName(gallery.ThumbnailsAbsolutePath, uploadedFile.SourceName); thumbnailFile.SaveAs(Path.Combine(gallery.ThumbnailsAbsolutePath, thumbnailName)); // Add file to the gallery gallery.Add(uploadedFile.SourceName, null, new string[] { thumbnailName }, null); // Save gallery gallery.Save(); } }
protected void rAsyncPDF_FileUploaded(object sender, FileUploadedEventArgs e) { bool bit = false; string folioCANT = folioCantidad(); if (folioCANT.ToString().Length > 0) { bit = true; } if (bit == true) { //string pathDirectoryPadre = HttpContext.Current.ApplicationInstance.Server.MapPath("~/reportes") + "\\" + Session["getIdAgencia"].ToString(); string pathDirectoryPadre = HttpContext.Current.ApplicationInstance.Server.MapPath("~/filecert") + "\\" + Session["getIdCentroUsr"].ToString(); //rAsyncPDF.TargetFolder = "~/reportes" + "\\" + Session["getIdAgencia"].ToString(); //+"\\" + Session["getIdTramite"] + e.File.GetExtension(); ; rAsyncPDF.TargetFolder = "~/filecert" + "\\" + Session["getIdCentroUsr"].ToString(); //+"\\" + Session["getIdTramite"] + e.File.GetExtension(); if (!Directory.Exists(pathDirectoryPadre)) { System.IO.Directory.CreateDirectory(pathDirectoryPadre.ToString()); //System.IO.Directory.CreateDirectory(pathDirectoryHijo.ToString()); } string newfilename = string.Format("{0}{1}", folioCANT.Trim().ToString(), e.File.GetExtension()); if (System.IO.File.Exists(Path.Combine(Server.MapPath(rAsyncPDF.TargetFolder), newfilename))) { System.IO.File.Delete(Path.Combine(Server.MapPath(rAsyncPDF.TargetFolder), newfilename)); } e.File.SaveAs(Path.Combine(Server.MapPath(rAsyncPDF.TargetFolder), newfilename), true); } }
/// <summary> /// Handles the OnFileUploaded event of the uploadedFile control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.FileUploadedEventArgs"/> instance containing the event data.</param> protected void uploadedFile_OnFileUploaded(object sender, FileUploadedEventArgs e) { if (!isPreviewed) { Preview(!(rgImportColumns.Items.Count > 0)); } }
protected void rauFotoEmpleado_FileUploaded(object sender, FileUploadedEventArgs e) { EliminarDocumento(vIdItemFotografia.ToString()); using (Stream fileStream = rauFotoEmpleado.UploadedFiles[0].InputStream) { using (System.Drawing.Image bitmapImage = UtilImage.ResizeImage(System.Drawing.Image.FromStream(fileStream), 200, 200)) { using (MemoryStream stream = new MemoryStream()) { vNbLogotipo = rauFotoEmpleado.UploadedFiles[0].GetName(); if ((vNbLogotipo.Length != 0) && (vNbLogotipo.Length >= 50)) { UtilMensajes.MensajeResultadoDB(rwmAlertas, "El nombre de la imagen no puede ser tan largo", E_TIPO_RESPUESTA_DB.WARNING, 400, 150, null); vNbLogotipo = null; return; } else { bitmapImage.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); vFiLogotipo = Convert.ToBase64String(stream.ToArray()); rbiFotoEmpleado.DataValue = stream.ToArray(); } } } } btnEliminarFotoEmpleado.Visible = true; AddDocumento("FOTOGRAFIA", rauFotoEmpleado); grdDocumentos.Rebind(); }
protected void rauFiles_FileUploaded(object sender, FileUploadedEventArgs e) { string filepath = ""; if (ImgList.Count >= 5) { RadAjaxManager1.Alert("最多上传5张图!"); return; } if (rauFiles.UploadedFiles.Count > 0) { foreach (UploadedFile file in rauFiles.UploadedFiles) { string uploadPath = "/UpLoad/" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "/"; if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(Server.MapPath(uploadPath)); } string name = DateTime.Now.ToString("yyyyMMddHHmmssff") + ".png"; filepath = Server.MapPath(uploadPath) + name; file.SaveAs(filepath); ImgModel img = new ImgModel(); img.ID = ImgList.Count + 1; img.imgUrl = uploadPath + name; ImgList.Add(img); RadListView1.Rebind(); } //imgPic.ImageUrl = uploadPath + name; } }
protected void Uploader1_FileUploaded(object sender, FileUploadedEventArgs e) { UploadedFile uploadedFile = e.UploadedFile; SourceGallery gallery = new SourceGallery(); // Is it new upload session? if (uploadedFile.Package.PackageIndex == 0 && uploadedFile.Index == 0) { // Remove previously uploaded files gallery.Empty(); } // Get source file ConvertedFile sourceFile = uploadedFile.ConvertedFiles[0]; if (sourceFile != null) { string sourceName = Utils.GetSafeFileName(gallery.UploadedFilesAbsolutePath, uploadedFile.SourceName); // Save file to the disk sourceFile.SaveAs(Path.Combine(gallery.UploadedFilesAbsolutePath, sourceName)); string description = uploadedFile.Description; // Add file to the gallery gallery.Add(uploadedFile.SourceName, sourceName, description); } // Save gallery gallery.Save(); }
public void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { // BtnSubmit.Visible = false; RefreshButton.Visible = true; RadAsyncUpload1.Visible = false; var liItem = new HtmlGenericControl("li"); liItem.InnerText = e.File.FileName; if (totalBytes < MaxTotalBytes) { // Total bytes limit has not been reached, accept the file e.IsValid = true; totalBytes += e.File.ContentLength; lblresult.Text = totalBytes.ToString(); } else { // Limit reached, discard the file e.IsValid = false; } if (e.IsValid) { ValidFiles.Visible = true; ValidFilesList.Controls.AddAt(0, liItem); //Dim image As Byte() } else { InvalidFiles.Visible = true; InValidFilesList.Controls.AddAt(0, liItem); } }
protected void Uploader1_FileUploaded(object sender, FileUploadedEventArgs e) { UploadedFile uploadedFile = e.UploadedFile; ThumbnailsGallery gallery = new ThumbnailsGallery(); // Image Uploader configured to upload 3 thumbnails for every selected to upload file int thumbnailCount = 3; string[] thumbnails = new string[thumbnailCount]; // Save thumbnails for (int i = 0; i < thumbnailCount; i++) { ConvertedFile thumbnailFile = uploadedFile.ConvertedFiles[i]; if (thumbnailFile != null) { string thumbnailName = Utils.GetSafeFileName(gallery.ThumbnailsAbsolutePath, thumbnailFile.Name); thumbnailFile.SaveAs(Path.Combine(gallery.ThumbnailsAbsolutePath, thumbnailName)); thumbnails[i] = thumbnailName; } } // Add file to the gallery gallery.Add(uploadedFile.SourceName, null, thumbnails, uploadedFile.Description); // Save gallery gallery.Save(); }
protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { string text = RadAsyncUpload1.UploadedFiles[0].GetFieldValue("TextBox"); InsertImage(e.File, 123, text); RadGrid1.Rebind(); }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { byte[] imageData; using (Stream stream = e.File.InputStream) { imageData = new byte[stream.Length]; stream.Read(imageData, 0, (int)stream.Length); } //save image string file = Server.MapPath("/Files/Verification/") + "\\" + e.File.FileName; //AsyncUpload1.UploadedFiles[0].SaveAs(file); string fullurl = Request.Url.AbsoluteUri; //string saveimgurl = //fullurl.Substring(0, fullurl.ToLower().IndexOf("order_form2.aspx")) + Thumbnail.ImageUrl.Replace("~/", ""); //sitetemp.savepicurl2(saveimgurl, file); FileStream fs = new FileStream(file, FileMode.Create); BinaryWriter w = new BinaryWriter(fs); try { w.Write(imageData); } finally { fs.Close(); w.Close(); } }
protected void FileImageAlbum_FileUploaded(object sender, FileUploadedEventArgs e) { var FileImageAlbum = (RadAsyncUpload)sender; //var Parent = FileImageAlbum.NamingContainer; //var ProductID = ((HiddenField)Parent.FindControl("hdnProductID")).Value; var ProductOptionCategoryID = string.IsNullOrEmpty(Request.QueryString["poi"]) ? "" : Request.QueryString["poi"]; //var RadListView1 = (RadListView)Parent.FindControl("RadListView1"); //var RadListView2 = (RadListView)Parent.FindControl("RadListView2"); string newName = Guid.NewGuid().GetHashCode().ToString("X") + e.File.GetExtension(); string targetFolder = "~/res/productoption/" + newName; e.File.SaveAs(Server.MapPath(targetFolder)); string bgColor = "#ffffff"; ResizeCropImage.CreateThumbNailWithBackGroundColor("~/res/productoption/", "~/res/productoption/thumbs/", newName, 95, 96, bgColor); ResizeCropImage.ResizeWithBackGroundColor(targetFolder, 486, 487, bgColor); //ResizeCropImage.ResizeByCondition(targetFolder + newName, 800, 800); //ResizeCropImage.CreateThumbNailByCondition("~/res/productoption/", "~/res/productoption/thumbs/", newName, 120, 120); if (string.IsNullOrEmpty(ProductOptionCategoryID)) { TempImage.Rows.Add(new object[] { newName }); RadListView1.DataSource = TempImage; RadListView1.DataBind(); } else { var oProductOption = new ProductOption(); oProductOption.ProductOptionInsert(newName, "", "", "", "", "", "", "", "", "", "", "", "", "", ProductOptionCategoryID, "1", "0", "0", "1", "", "" ); RadListView1.DataBind(); } }
/// <summary> /// Handles the OnFileUploaded event of the rauLogo control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.FileUploadedEventArgs"/> instance containing the event data.</param> protected void rauLogo_OnFileUploaded(object sender, FileUploadedEventArgs e) { var fileName = FileSystemProvider.Upload(CurrentUser.Instance.SiteID, "Portal", e.File.FileName, e.File.InputStream, FileType.Image); CurrentLogo = fileName; rbiLogo.ImageUrl = FileSystemProvider.GetLink(CurrentUser.Instance.SiteID, "Portal", fileName, FileType.Image); }
protected void publish_attachment_upload_OnFileUploaded(object sender, FileUploadedEventArgs e) { var id = CurrentResource.Id; var file = e.File; ResourceFileType type; switch (file.GetExtension().Replace(".", "")) { case "jpg": case "jpeg": case "png": case "gif": case "bmp": type = ResourceFileType.Image; break; case "rar": case "zip": case "7z": type = ResourceFileType.Zip; break; case "doc": case "docx": case "txt": case "rtf": type = ResourceFileType.Word; break; case "ppt": case "pptx": type = ResourceFileType.Powerpoint; break; case "xls": case "xlsx": type = ResourceFileType.Excel; break; case "pdf": type = ResourceFileType.Pdf; break; case "mp3": case "wma": type = ResourceFileType.Audio; break; default: type = ResourceFileType.Media; break; } var name = string.Format("../Common/资源/{2}/附件/{1}_{0}", file.FileName, HomoryContext.Value.GetId(), CurrentUser.Id.ToString().ToUpper()); file.SaveAs(Server.MapPath(name), true); var ra = new ResourceAttachment { Id = HomoryContext.Value.GetId(), ResourceId = id, FileType = type, Title = file.GetName(), Source = name, State = State.启用 }; HomoryContext.Value.ResourceAttachment.Add(ra); HomoryContext.Value.SaveChanges(); }
protected void Uploader1_FileUploaded(object sender, FileUploadedEventArgs e) { UploadedFile uploadedFile = e.UploadedFile; SourceGallery gallery = new SourceGallery(); if (!string.IsNullOrEmpty(Request["hashcheck"])) { if (hashes == null) { hashes = new List<string>(); foreach (Dictionary<string, string> item in gallery.GetItems()) { hashes.Add(item["description"]); } } string hash = uploadedFile.Package.PackageFields["HashCodeMD5_" + uploadedFile.Index]; if (hashes.Contains(hash)) { existedFiles.Add(uploadedFile.Index.ToString()); } // Last uploaded file? if (uploadedFile.Index == uploadedFile.Package.PackageFileCount - 1) { Response.ClearContent(); Response.Write(string.Join(";", existedFiles.ToArray())); Response.End(); } return; } // Is it new upload session? if (uploadedFile.Package.PackageIndex == 0 && uploadedFile.Index == 0 && !string.IsNullOrEmpty(Request["clean"])) { // Remove previously uploaded files gallery.Empty(); } // Get source file ConvertedFile sourceFile = uploadedFile.ConvertedFiles[0]; if (sourceFile != null) { string sourceName = Utils.GetSafeFileName(gallery.UploadedFilesAbsolutePath, uploadedFile.SourceName); // Save file to the disk sourceFile.SaveAs(Path.Combine(gallery.UploadedFilesAbsolutePath, sourceName)); string hash = uploadedFile.Package.PackageFields["HashCodeMD5_" + uploadedFile.Index]; // Add file to the gallery gallery.Add(uploadedFile.SourceName, sourceName, hash); } // Save gallery gallery.Save(); }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { using (Stream stream = e.File.InputStream) { imgdata = new byte[stream.Length]; stream.Read(imgdata, 0, (int)stream.Length); AnhScan.DataValue = imgdata; } }
protected void RadAsyncUploadImg_FileUploaded(object sender, FileUploadedEventArgs e) { RadAsyncUpload UL = (RadAsyncUpload)sender; HiddenField HFimg = (HiddenField)UL.Parent.FindControl("HFimg"); string time = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".jpg"; string FPath = MapPath("../../CourseFiles/Concilor/"); e.File.SaveAs(FPath + time); HFimg.Value = time; }
protected void FileUploadFlightInfo_FileUploaded(object sender, FileUploadedEventArgs e) { UploadedFile file = e.File; fileExtension = file.GetExtension(); fileName = file.GetName(); path = Server.MapPath("~/Upload/"); file.SaveAs(path + fileName); }
protected void RadAsyncUploadControl_OnFileUploaded(object sender, FileUploadedEventArgs e) { using (Stream stream = e.File.InputStream) { byte[] imageData = new byte[stream.Length]; stream.Read(imageData, 0, (int)stream.Length); FillImageData(stream); ImageRadBinaryImage.Visible = true; } }
protected void rauFoto_FileUploaded(object sender, FileUploadedEventArgs e) { /* * BinaryReader reader = new BinaryReader(e.File.InputStream); * Byte[] data = reader.ReadBytes((int)e.File.InputStream.Length); * imgPrePhoto.DataValue = data; * imgPrePhoto.Width = new Unit(250, UnitType.Pixel); * imgPrePhoto.Height = new Unit(300, UnitType.Pixel); */ }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { Context.Cache.Remove(Session.SessionID + "UploadedFile"); using (Stream stream = e.File.InputStream) { byte[] imgData = new byte[stream.Length]; stream.Read(imgData, 0, (int)stream.Length); rbiImage.DataValue = imgData; } }
protected void multiFileUpload_FileUploaded(object sender, FileUploadedEventArgs e) { // No Loop needed multiFileUpload_FileUploaded will be called for each file uploaded strHeaderFileName = e.File.FileName; // Use the filename as the Header Name var strHeaderName = strHeaderFileName.Replace(".jpg", ""); // allow Underscore characters in FileName to become Spaces in the Display Name. strHeaderName = strHeaderName.Replace("_", " "); }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { var fileUpload = (RadAsyncUpload)sender; if (fileUpload.UploadedFiles.Count > 0) { UploadedFile file = fileUpload.UploadedFiles[0]; SessionInfo.CurrentResourceLink.ThumbNail = "/images/thumbnails/{0}".FormatWith(file.GetName()); file.SaveAs("{0}/{1}".FormatWith(Server.MapPath("~/images/thumbnails"), file.GetName()), true); } }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { using (Stream stream = e.File.InputStream) { imgdata = new byte[stream.Length]; stream.Read(imgdata, 0, (int)stream.Length); AnhNV.DataValue = imgdata; AnhNV.Height = Unit.Pixel(120); AnhNV.Width = Unit.Pixel(90); } }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { if (e.File.ContentLength < MaxTotalBytes) { e.IsValid = true; } else { e.IsValid = false; lblMensaje.Text = "El tamaño del archivo debe ser menor a 1MB"; } }
void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { e.IsValid = true; return; // string temppath = RadAsyncUpload1.TemporaryFolder; // !CheckUploadedFileValidity(); // string fileNameChanged = e.File.GetFieldValue("TextBox"); // Label fileName = new Label(); // // fileName.Text = e.File.FileName; // string physicalSourceFolder = HttpContext.Current.Server.MapPath(RadAsyncUpload1.TemporaryFolder); // string sourceFile = physicalSourceFolder + @"\" + e.File.FileName; // string physicalFolder = HttpContext.Current.Server.MapPath(hiddenUploadPath.Value); // string destFile = physicalFolder + @"\" + e.File.FileName; // e.IsValid = true; /* if (System.IO.File.Exists(sourceFile) == false) * e.IsValid = false; * else * { * try * { * System.IO.File.Move(sourceFile, destFile); * } * catch (Exception ex) * { * string s = ex.Message; * e.IsValid = false; * } * } * * * if (e.IsValid) * { * ValidFiles.Visible = true; * ValidFiles.Controls.Add(fileName); * } * else * { * InvalidFiles.Visible = true; * InvalidFiles.Controls.Add(fileName); * * } */ }
public void RadAsyncUploadFileUploaded(object sender, FileUploadedEventArgs e) { var adm = (ObjLogin)Session["objLogin"]; var fileName = string.Format("{0}_{1}", adm.Id, e.File.GetName()); var fullPath = Server.MapPath(Path.Combine(dashboardAttachedFile.TargetFolder, fileName)); e.IsValid = false; e.File.SaveAs(fullPath, true); Session[FilePathSessionKey] = fullPath; Session[FileNameSessionKey] = fileName; }
protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { try { lblMessageError.Text = ""; lblMessageSuccess.Text = ""; //lblXmlFile.Text = e.File.FileName; } catch (Exception ex) { lblMessageError.Text = ex.Message; } }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { try { // First thing we do is check if we need to create or retrieve and album if (_album == null && Request["a"] != null) { long aId = Convert.ToInt64(Request["a"]); aqufitEntities entities = new aqufitEntities(); if (aId == 0) // this is a new album { Album album = new Album() { Name = txtAlbumName.Text, CreationDate = DateTime.Now.ToUniversalTime(), UserSetting = entities.UserSettings.FirstOrDefault(us => us.Id == UserSettings.Id) }; entities.AddToAlbums(album); entities.SaveChanges(); _album = entities.Albums.OrderByDescending(a => a.Id).FirstOrDefault(a => a.UserSetting.Id == UserSettings.Id); } else { _album = entities.Albums.OrderByDescending(a => a.Id).FirstOrDefault(a => a.Id == aId); } } else if (Request["a"] == null) { // should never see this ... sanity check.. RadAjaxManager1.ResponseScripts.Add("alert('No Album specified for the photos'); "); return; } if (e.File.ContentLength < 10072000) { e.IsValid = true; byte[] buffer = new byte[e.File.ContentLength]; using (Stream str = e.File.InputStream) { str.Read(buffer, 0, e.File.ContentLength); MemoryStream ms = new MemoryStream(buffer); Affine.Utils.ImageUtil.SavePhoto(Affine.Utils.ImageUtil.AlbumType.USER, ms, UserSettings.Id, _album.Id, userPhotoPath, urlPath, _album.Photo == null); } } } catch (Exception ex) { RadAjaxManager1.ResponseScripts.Add("alert('" + ex.Message + "'); "); } }
protected void OnFileUploaded(object sender, FileUploadedEventArgs e) { //Clear changes and remove uploaded image from Cache this.RadImageEditor1.ResetChanges(); using (Stream stream = e.File.InputStream) { byte[] imgData = new byte[stream.Length]; stream.Read(imgData, 0, imgData.Length); MemoryStream ms = new MemoryStream(); ms.Write(imgData, 0, imgData.Length); this.ImageInMemory = ms; } }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { //Clear changes and remove uploaded image from Cache Context.Cache.Remove(Session.SessionID + "UploadedFile"); using (Stream stream = e.File.InputStream) { byte[] imgData = new byte[stream.Length]; stream.Read(imgData, 0, imgData.Length); MemoryStream ms = new MemoryStream(); ms.Write(imgData, 0, imgData.Length); Context.Cache.Insert(Session.SessionID + "UploadedFile", ms, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero); } }
public void RadAsyncUpload_FileUploaded(object sender, FileUploadedEventArgs e) { e.File.SaveAs(BLL.Theme.Path + e.File.FileName); // Save the file BLL.Theme.ExtractZippedData(e.File.FileName); // Extract the contents BLL.Theme.DeleteZippedFile(e.File.FileName); // Delete the zipped file // Refresh the Theme combo box GridEditFormItem gridItem = (sender as RadAsyncUpload).NamingContainer as GridEditFormItem; RadComboBox ddTheme = (RadComboBox)gridItem.FindControl("ddTheme"); entityKey = (int)gridItem.GetDataKeyValue(this.RadGridKey); SetddThemeItems(ddTheme); SetddThemeSelectedValue(ddTheme); }
protected void uplFile_FileUploaded(object sender, FileUploadedEventArgs e) { string fullPath = Server.MapPath(fileUploadFolder); bool exists = System.IO.Directory.Exists(fullPath); if (!exists) { System.IO.Directory.CreateDirectory(fullPath); } string newfilename = DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss") + "_" + e.File.GetNameWithoutExtension().Replace(" ", "_") + e.File.GetExtension(); uploadedFilePath = fileUploadFolder + newfilename; e.File.SaveAs(System.IO.Path.Combine(fullPath, newfilename)); }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { Thumbnail.Width = Unit.Pixel(550); Thumbnail.Height = Unit.Pixel(410); using (Stream stream = e.File.InputStream) { byte[] imageData = new byte[stream.Length]; stream.Read(imageData, 0, (int)stream.Length); Thumbnail.DataValue = imageData; } }
protected void rauArchivo_FileUploaded(object sender, FileUploadedEventArgs e) { if (Session["Usuario"] == null) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "mykey", "CancelEdit();", true); } try { String path = Server.MapPath("~/Images/Noticia"); if (e.IsValid) { string imgPath = Path.Combine(path, e.File.FileName); e.File.InputStream.Dispose(); e.File.InputStream.Close(); e.File.SaveAs(imgPath, true); //NoticiaFoto_ListarResult imagen = new NoticiaFoto_ListarResult(); NoticiaFoto_ListarResult picture = new NoticiaFoto_ListarResult(); picture.urlImagen = e.File.FileName; picture.idNoticiaFoto = 0; picture.descripcion = ""; picture.activo = true; picture.elimino = false; //System.Drawing.Image img = System.Drawing.Image.FromStream(e.File.InputStream); System.Drawing.Image img = System.Drawing.Image.FromFile(imgPath); if (img.Width < img.Height) { picture.horizontal = false; } else { picture.horizontal = true; } picture.altura = img.Height; picture.anchura = img.Width; img.Dispose(); List <NoticiaFoto_ListarResult> lstFotos = JsonHelper.JsonDeserialize <List <NoticiaFoto_ListarResult> >((string)ViewState["lstFotos"]); lstFotos.Add(picture); ViewState["lstFotos"] = JsonHelper.JsonSerializer(lstFotos); } } catch (Exception ex) { lblMensaje.Text = "Error: " + ex.Message; lblMensaje.CssClass = "mensajeError"; } }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { //Clear changes and remove uploaded image from Cache RadImageEditor1.ResetChanges(); Context.Cache.Remove(Session.SessionID + "UploadedFile"); using (Stream stream = e.File.InputStream) { byte[] imgData = new byte[stream.Length]; stream.Read(imgData, 0, imgData.Length); MemoryStream ms = new MemoryStream(); ms.Write(imgData, 0, imgData.Length); Context.Cache.Insert(Session.SessionID + "UploadedFile", ms, null, DateTime.Now.AddMinutes(20), TimeSpan.Zero); } }
private void OnFileUploaded(object sender, FileUploadedEventArgs e) { Action action = () => { var paperclipsViewModel = DataContext as IPaperclipsViewModel; if (paperclipsViewModel != null) paperclipsViewModel.OnFileUploaded(sender, e); }; if (Dispatcher.CheckAccess()) action(); else Dispatcher.BeginInvoke(action); }
protected void RadAsyncUpload1_FileUploaded1(object sender, FileUploadedEventArgs e) { string strPeriodo; string fullPath; string Destino = ""; string savePath = "c:\\temp\\uploads\\"; int Anho, Mes, Dia; List <DataTable> tablas = new List <DataTable>(); DataTable tabla = new DataTable(); try { if (Panel1.CssClass == "background1") { Panel1.CssClass = "background2"; } else { Panel1.CssClass = "background1"; } strPeriodo = Request.QueryString["Periodo"].ToString(); Anho = int.Parse(strPeriodo.Substring(0, 4)); Mes = int.Parse(strPeriodo.Substring(4, 2)); Dia = int.Parse(strPeriodo.Substring(6, 2)); string strFecha = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "_"; fullPath = Path.Combine(savePath, strFecha + e.File.GetName()); e.File.SaveAs(fullPath); Destino = fullPath; tabla = LEER_EXCEL(Destino, "NumerosUnicos"); tablas = REGISTRAR_EXCEL(tabla, Anho, Mes, Dia); } catch (Exception ex) { lblMensaje.Text = "ERROR: " + ex.Message; lblMensaje.CssClass = "mensajeError"; } }
public void Upload() { FileUploadedEventArgs e = new FileUploadedEventArgs() { FileProgress = 100 }; while (e.FileProgress > 0) { e.FileProgress--; if (FileUploaded != null) { FileUploaded(this, e); } } }
public void aupPhoto_FileUploaded(object sender, FileUploadedEventArgs e) { Session["FolderType"] = "Profile"; telerikAsyncUploadResult result = e.UploadResult as telerikAsyncUploadResult; if (result != null) { if (result.DocumentID > 0) { hProfileImgID.Value = result.DocumentID.ToString(); UpdatePresenterProfileID(result.DocumentID, Convert.ToInt32(hPresenterID.Value)); aupPhoto.Visible = false; //imgprofileImg.Src = "~/handler/showImage.ashx?ID=" + result.DocumentID.ToString(); refreshNav2Tab2(); } } }
protected void FileImageName_FileUploaded(object sender, FileUploadedEventArgs e) { var FileImageName = (RadAsyncUpload)sender; var Parent = FileImageName.NamingContainer; var hdnNewImageName = (HiddenField)Parent.FindControl("hdnNewImageName"); string targetFolder = "~/res/product/"; string newName = Guid.NewGuid().GetHashCode().ToString("X") + e.File.GetExtension(); e.File.SaveAs(Server.MapPath(targetFolder + newName)); ResizeCropImage.ResizeByCondition(targetFolder + newName, 800, 800); ResizeCropImage.CreateThumbNailByCondition("~/res/product/", "~/res/product/thumbs/", newName, 120, 120); hdnNewImageName.Value = newName; }
protected void Uploader1_FileUploaded(object sender, FileUploadedEventArgs e) { UploadedFile uploadedFile = e.UploadedFile; WizardGallery gallery = new WizardGallery(); // Is it new upload session? if (uploadedFile.Package.PackageIndex == 0 && uploadedFile.Index == 0) { // Remove previously uploaded files gallery.Empty(); // Add common info to galllery NameValueCollection form = Request.Form; Dictionary<string, string> values = new Dictionary<string, string>(); values.Add("propertytype", form["propertyTypeDropDownList"]); values.Add("headline", form["headlineTextBox"]); values.Add("description", form["descriptionTextBox"]); values.Add("price", form["priceTextBox"]); values.Add("number", form["numberTextBox"]); values.Add("street", form["streetTextBox"]); values.Add("city", form["cityTextBox"]); values.Add("zipcode", form["zipCodeTextBox"]); values.Add("bedrooms", form["bedroomsDropDownList"]); values.Add("bathrooms", form["bathroomsDropDownList"]); values.Add("square", form["squareTextBox"]); gallery.UpdateCommonInfo(values); } // Save files ConvertedFile sourceFile = uploadedFile.ConvertedFiles[0]; ConvertedFile thumbnailFile = uploadedFile.ConvertedFiles[1]; if (sourceFile != null && thumbnailFile != null) { string sourceFileName = Utils.GetSafeFileName(gallery.UploadedFilesAbsolutePath, sourceFile.Name); sourceFile.SaveAs(Path.Combine(gallery.UploadedFilesAbsolutePath, sourceFileName)); string thumbnailFileName = Utils.GetSafeFileName(gallery.UploadedFilesAbsolutePath, thumbnailFile.Name); thumbnailFile.SaveAs(Path.Combine(gallery.ThumbnailsAbsolutePath, thumbnailFileName)); // Add file to the gallery gallery.Add(uploadedFile.SourceName, sourceFileName, new string[] { thumbnailFileName }, uploadedFile.Description); } // Save gallery gallery.Save(); }
public void aupLogo_FileUploaded(object sender, FileUploadedEventArgs e) { telerikAsyncUploadResult result = e.UploadResult as telerikAsyncUploadResult; if (result != null) { if (result.DocumentID > 0) { WebinarResource objWebinarResource = new WebinarResource(); objWebinarResource.WebinarID = Convert.ToInt32(hWebinarID.Value); objWebinarResource.DocID = result.DocumentID; objWebinarResource.ResourceType = (rcmbHeader.SelectedValue == "BANNER" ? "BANNER" : "Logo"); objWebinarResource.ResourceTitle = e.File.FileName; objWebinarResource.ResourceValue = ""; objWebinarResource.IsBriefcase = false; objWebinarDA.InsertWebinarResources(objWebinarResource); } } }
public void aupPhoto_FileUploaded(object sender, FileUploadedEventArgs e) { Session["FolderType"] = "Profile"; telerikAsyncUploadResult result = e.UploadResult as telerikAsyncUploadResult; if (result != null) { if (result.DocumentID > 0) { //objWebinarDA.UpdatePresenterProfileDoc(result.DocumentID, Convert.ToInt32(Session["UserID"])); hProfileImgID.Value = result.DocumentID.ToString(); //DocAccess objDocAccess = new DocAccess(); //objDocAccess.resizeImage(result.DocumentID, Convert.ToInt32(Session["ClientID"])); aupPhoto.Visible = false; imgprofileImg.Src = "~/handler/MyProfilePhoto.ashx?ID=" + Convert.ToString(Session["UserID"]); dvToggle(); } } }
protected void upload_FileUploaded(object sender, FileUploadedEventArgs e) { using (var upload = sender as RadAsyncUpload) { // ReSharper disable PossibleNullReferenceException if (upload.UploadedFiles.Count > 0) // ReSharper restore PossibleNullReferenceException { var id = Guid.Parse(Request.QueryString[0]); var path = string.Format("~/Common/头像/应用/{0}.png", id); upload.UploadedFiles[0].SaveAs(Server.MapPath(path), true); var app = HomoryContext.Value.Application.Single(o => o.Id == id); app.Icon = path; HomoryContext.Value.SaveChanges(); } } panelInner.ResponseScripts.Add("RadClose();"); }
protected void Uploader1_FileUploaded(object sender, FileUploadedEventArgs e) { UploadedFile uploadedFile = e.UploadedFile; ThumbnailsGallery gallery = new ThumbnailsGallery(); // Is it new upload session? if (uploadedFile.Package.PackageIndex == 0 && uploadedFile.Index == 0) { // Remove previously uploaded files gallery.Empty(); } // Save uploaded files int thumbnailCount = 2; string[] thumbnailNames = new string[thumbnailCount]; for (int i = 0; i < thumbnailCount; i++) { ConvertedFile thumbnailFile = uploadedFile.ConvertedFiles[i]; if (thumbnailFile != null) { // Save thumbnail string thumbnailName = Utils.GetSafeFileName(gallery.ThumbnailsAbsolutePath, thumbnailFile.Name); thumbnailFile.SaveAs(Path.Combine(gallery.ThumbnailsAbsolutePath, thumbnailName)); thumbnailNames[i] = thumbnailName; } } // Get Title value string title = uploadedFile.Package.PackageFields["Title_" + uploadedFile.Index]; // Use original file name if title was not specified if (string.IsNullOrEmpty(title)) { title = uploadedFile.SourceName; } // Add file to the gallery gallery.Add(title, null, thumbnailNames, uploadedFile.Description); // Save gallery gallery.Save(); }
public void aupContent_FileUploaded(object sender, FileUploadedEventArgs e) { telerikAsyncUploadResult result = e.UploadResult as telerikAsyncUploadResult; if (result != null) { if (result.DocumentID > 0) { WebinarResource objWebinarResource = new WebinarResource(); objWebinarResource.WebinarID = Convert.ToInt32(hWebinarID.Value); objWebinarResource.DocID = result.DocumentID; objWebinarResource.ResourceType = "Content Doc"; objWebinarResource.ResourceTitle = e.File.FileName; objWebinarResource.ResourceValue = ""; objWebinarResource.IsBriefcase = true; objWebinarDA.InsertWebinarResources(objWebinarResource); popResource(); } } }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { string file = Server.MapPath("/Files/UserImages/") + "\\" + currentuser.User_key.ToString() + ".jpg"; if (currentuser.Image_url != null) { File.Delete(file); } byte[] imageData; using (Stream stream = e.File.InputStream) { imageData = new byte[stream.Length]; stream.Read(imageData, 0, (int)stream.Length); } //save image //AsyncUpload1.UploadedFiles[0].SaveAs(file); string fullurl = Request.Url.AbsoluteUri; //string saveimgurl = //fullurl.Substring(0, fullurl.ToLower().IndexOf("order_form2.aspx")) + Thumbnail.ImageUrl.Replace("~/", ""); //sitetemp.savepicurl2(saveimgurl, file); FileStream fs = new FileStream(file, FileMode.Create); BinaryWriter w = new BinaryWriter(fs); try { w.Write(imageData); } finally { fs.Close(); w.Close(); } currentuser = sitetemp.getcurrentuser(false); Insertimgurl(); imguser.ImageUrl += "?r=" + DateTime.Now.TimeOfDay.ToString(); }
//protected void aupLogo_FileUploaded(object sender, FileUploadedEventArgs e) //{ // RadBinaryImage rimg = (RadBinaryImage)this.FindControl("Thumbnail" + hCurrentImg.Value); // if (rimg != null) // { // rimg.Width = Unit.Pixel(200); // rimg.Height = Unit.Pixel(150); // using (Stream stream = e.File.InputStream) // { // byte[] imageData = new byte[stream.Length]; // stream.Read(imageData, 0, (int)stream.Length); // rimg.DataValue = imageData; // } // int curr = Convert.ToInt32(hCurrentImg.Value); // if (curr < 4) // { // hCurrentImg.Value = (curr + 1).ToString(); // if (curr >= 4) // aupLogo.Visible = false; // } // } //} public void aupLogo_FileUploaded(object sender, FileUploadedEventArgs e) { telerikAsyncUploadResult result = e.UploadResult as telerikAsyncUploadResult; if (result != null) { if (result.DocumentID > 0) { int idx = Convert.ToInt32(hCurrentImg.Value); if (rcmbHeader.SelectedIndex != 1) idx = 1; WebinarResource objWebinarResource = new WebinarResource(); objWebinarResource.WebinarID = Convert.ToInt32(hWebinarID.Value); objWebinarResource.DocID = result.DocumentID; objWebinarResource.ResourceType = rcmbHeader.SelectedValue; objWebinarResource.ResourceOrder = idx; objWebinarDA.InsertRegFormResources(objWebinarResource); ++idx; hCurrentImg.Value = idx.ToString(); } } }
protected void uplImagem_OnFileUploaded(object sender, FileUploadedEventArgs e) { try { if (uplImagem.UploadedFiles.Count > 0) { var arquivo = uplImagem.UploadedFiles[0]; var pastaDeDestino = Server.MapPath(Util.URL_IMAGEM_CABECALHO_BOLETO); Compartilhados.Util.CrieDiretorio(pastaDeDestino); var caminhoArquivo = Path.Combine(pastaDeDestino, arquivo.GetNameWithoutExtension() + arquivo.GetExtension()); arquivo.SaveAs(caminhoArquivo); imgImagem.ImageUrl = string.Concat(Util.URL_IMAGEM_CABECALHO_BOLETO, "/", arquivo.GetNameWithoutExtension() + arquivo.GetExtension()); } } catch (Exception ex) { Logger.GetInstancia().Erro("Erro ao carregar imagem, exceção: ", ex); } }
protected void Uploader1_FileUploaded(object sender, FileUploadedEventArgs e) { UploadedFile uploadedFile = e.UploadedFile; ThumbnailsGallery gallery = new ThumbnailsGallery(); // Is it new upload session? if (uploadedFile.Package.PackageIndex == 0 && uploadedFile.Index == 0) { // Remove previously uploaded files gallery.Empty(); } // Save files ConvertedFile sourceFile = uploadedFile.ConvertedFiles[0]; ConvertedFile thumbnailFile = uploadedFile.ConvertedFiles[1]; if (sourceFile != null && thumbnailFile != null) { string sourceFileName = Utils.GetSafeFileName(gallery.UploadedFilesAbsolutePath, sourceFile.Name); sourceFile.SaveAs(Path.Combine(gallery.UploadedFilesAbsolutePath, sourceFileName)); string thumbnailFileName = Utils.GetSafeFileName(gallery.UploadedFilesAbsolutePath, thumbnailFile.Name); thumbnailFile.SaveAs(Path.Combine(gallery.ThumbnailsAbsolutePath, thumbnailFileName)); string description = uploadedFile.Tag; if (!string.IsNullOrEmpty(description)) { NameValueCollection data = HttpUtility.ParseQueryString(description); description = string.Format("Size: {0}<br />Paper: {1}<br />Quantity: {2}", HttpUtility.HtmlEncode(data["Size"]), HttpUtility.HtmlEncode(data["Paper"]), HttpUtility.HtmlEncode(data["Quantity"])); } // Add file to the gallery gallery.Add(uploadedFile.SourceName, sourceFileName, new string[] { thumbnailFileName }, description); // Save gallery gallery.Save(); } }
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) { string startTime = Request["__EVENTARGUMENT"]; string localUploadpath = Server.MapPath("~/Uploads/"); e.File.SaveAs(localUploadpath + e.File.GetName()); if (e.File.GetExtension().Trim().Length == 0) { Response.Write("Error: The document selected has an invalid file extension."); FileInfo fileInfo = new FileInfo(localUploadpath + e.File.GetName()); fileInfo.Delete(); pnlDone.Visible = false; } else { KCreate.CreateDoc(localUploadpath + e.File.GetName(), ws, fldr, isObjID, (double.Parse(startTime)).GetJSDateTimeToLocal(), isAdmin); FileInfo fileInfo = new FileInfo(localUploadpath + e.File.FileName); fileInfo.Delete(); } }
protected void FileImageAlbum_FileUploaded(object sender, FileUploadedEventArgs e) { var FileImageAlbum = (RadAsyncUpload)sender; var Parent = FileImageAlbum.NamingContainer; var ProductID = ((HiddenField)Parent.FindControl("hdnProductID")).Value; var RadListView1 = (RadListView)Parent.FindControl("RadListView1"); var RadListView2 = (RadListView)Parent.FindControl("RadListView2"); string targetFolder = "~/res/product/album/"; string newName = Guid.NewGuid().GetHashCode().ToString("X") + e.File.GetExtension(); e.File.SaveAs(Server.MapPath(targetFolder + newName)); //ResizeCropImage.ResizeByCondition(targetFolder + newName, 800, 800); //ResizeCropImage.CreateThumbNailByCondition("~/res/product/album/", "~/res/product/album/thumbs/", newName, 120, 120); if (string.IsNullOrEmpty(ProductID)) { TempImage.Rows.Add(new object[] { newName }); RadListView2.DataSource = TempImage; RadListView2.DataBind(); } else { var oProductImage = new ProductImage(); oProductImage.ProductImageInsert(newName, "", "", "", "", "", ProductID, "True", ""); RadListView1.Rebind(); } }
protected void FileImageName_FileUploaded(object sender, FileUploadedEventArgs e) { var FileImageName = (RadAsyncUpload)sender; var Parent = FileImageName.NamingContainer; var hdnNewImageName = (HiddenField)Parent.FindControl("hdnNewImageName"); string targetFolder = "~/res/product/"; string newName = Guid.NewGuid().GetHashCode().ToString("X") + e.File.GetExtension(); e.File.SaveAs(Server.MapPath(targetFolder + newName)); //ResizeCropImage.ResizeByCondition(targetFolder + newName, 800, 800); //ResizeCropImage.CreateThumbNailByCondition("~/res/product/", "~/res/product/thumbs/", newName, 120, 120); hdnNewImageName.Value = newName; }
protected void publish_attachment_upload_OnFileUploaded(object sender, FileUploadedEventArgs e) { var aid = HomoryContext.Value.GetId(); var id = CurrentResource.Id; var file = e.File; var name = string.Format("../Common/资源/{2}/附件/{1}_{0}", file.FileName, aid, CurrentUser.Id.ToString().ToUpper()); var sourceX = Server.MapPath(name); var pathX = string.Format("../Common/资源/{2}/附件/{1}_{0}", file.GetNameWithoutExtension(), aid, CurrentUser.Id.ToString().ToUpper()); file.SaveAs(Server.MapPath(name), true); ResourceFileType type; switch (file.GetExtension().Replace(".", "")) { case "jpg": case "jpeg": case "png": case "gif": case "bmp": type = ResourceFileType.Image; break; case "rar": case "zip": case "7z": type = ResourceFileType.Zip; break; case "doc": case "docx": case "txt": case "rtf": type = ResourceFileType.Word; pathX += ".pdf"; pathX = Server.MapPath(pathX); var docW = new Aspose.Words.Document(sourceX); docW.Save(pathX, Aspose.Words.SaveFormat.Pdf); break; case "ppt": case "pptx": type = ResourceFileType.Powerpoint; pathX += ".pdf"; pathX = Server.MapPath(pathX); var docP = new Aspose.Slides.Presentation(sourceX); docP.Save(pathX, Aspose.Slides.Export.SaveFormat.Pdf); break; case "xls": case "xlsx": type = ResourceFileType.Excel; pathX += ".pdf"; pathX = Server.MapPath(pathX); var docE = new Aspose.Cells.Workbook(sourceX); docE.Save(pathX, Aspose.Cells.SaveFormat.Pdf); break; case "pdf": type = ResourceFileType.Pdf; break; case "mp3": case "wma": type = ResourceFileType.Audio; break; default: type = ResourceFileType.Media; break; } var ra = new ResourceAttachment { Id = aid, ResourceId = id, FileType = type, Title = file.GetName(), Remark = remarkTextbox.Text, Source = name, State = State.启用 }; HomoryContext.Value.ResourceAttachment.Add(ra); HomoryContext.Value.SaveChanges(); }
private void RadUpload_FileUploaded(object sender, FileUploadedEventArgs e) { Uri uri = ConstructAbsoluteUri(new Uri(this.RadUpload1.UploadServiceUrl, UriKind.RelativeOrAbsolute)); string imageURL = uri.AbsoluteUri.Remove(uri.AbsoluteUri.LastIndexOf("/")) + "/" + RadUpload1.TargetFolder + "/" + e.SelectedFile.Name; Image img = new Image(); BitmapImage bmp = new BitmapImage(new Uri(imageURL, UriKind.RelativeOrAbsolute)); img.ImageFailed += this.NewImage_ImageFailed; img.Source = bmp; img.Margin = new Thickness(1); img.Stretch = System.Windows.Media.Stretch.Uniform; ImageGalleryItem item = new ImageGalleryItem(); item.FileSize = this.FormatSize(e.SelectedFile.Size); item.FileName = e.SelectedFile.Name; item.SetImage(img); item.ActionButtonClicked += this.ItemActionButtonHandler; this.ImageContainer.Children.Add(item); }