예제 #1
0
    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();
        }
    }
예제 #2
0
    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();
    }
예제 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ThumbnailsGallery gallery = new ThumbnailsGallery();
         UploadedFilesRepeater.DataSource = gallery.GetItems();
         DataBind();
     }
 }
예제 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.HttpMethod == "GET" && !IsPostBack)
     {
         ThumbnailsGallery gallery = new ThumbnailsGallery();
         // Remove previously uploaded files
         gallery.Empty();
     }
 }
예제 #5
0
    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();
    }
예제 #6
0
    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();
        }
    }