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 Page_Load(object sender, EventArgs e) { if (Request.HttpMethod == "GET" && !IsPostBack) { ThumbnailsGallery gallery = new ThumbnailsGallery(); // Remove previously uploaded files gallery.Empty(); } }
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(); }
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(); } }