Progress Area

Thread is closed for posting
4 posts, 1 answers
  1. David S
    David S avatar
    11 posts
    Member since:
    May 2008

    Posted 22 Jul 2008 Link to this post

    Hello,

    I am using the RadUpload control to add multiple files to the server this was working fine until I added the Progress Area.

    Everything works fine the first time around e.g. I can upload multiple files and the progress area displays.  However in the same session, when I navigate  back to my upload page and try to upload more files, the HttpFileCollection does not detected that I have selected any (the size of the collection is zero).  Here is the code in adding files to the server:

            public bool UploadFilesToServer() 
            { 
                bool validPost = false
                if (Page.IsPostBack) 
                { 
                    DirectoryInfo parentDir = new DirectoryInfo(Page.Server.MapPath("./SessionFolders/") + UniqueIndentifier + "/"); 
                     
                    if (parentDir.Exists) 
                    { 
                        foreach (FileInfo oldfile in parentDir.GetFiles()) 
                            oldfile.Delete(); 
                    } 
                    HttpFileCollection uploadFilCol = Page.Request.Files; 
                    for (int i = 0; i < uploadFilCol.Count; i++) 
                    { 
     
                        HttpPostedFile file = uploadFilCol[i]; 
                        string fileName = Path.GetFileName(file.FileName); 
                        if (fileName != string.Empty) 
                        { 
                            //Create Folder if neccesary 
                            if (!parentDir.Exists) 
                                parentDir.Create(); 
     
                            try 
                            { 
                                file.SaveAs(parentDir.ToString() + fileName); 
                                validPost = true
                            } 
                            catch (Exception) { } 
                        } 
                    } 
     
                    if (!validPost)                 
                        MessageBox("Please select at least one file."); 
                     
                } 
     
                return validPost; 
            } 

    Thanks,
    David
  2. Erjan Gavalji
    Admin
    Erjan Gavalji avatar
    1455 posts

    Posted 23 Jul 2008 Link to this post

    Hi David,

    The problem you encounter is caused by the RadUploadHttpModule. The current file upload processing model of the module extracts the files from the Request.Files collection and adds them to the RadUploadContext.Current. What you can do is use RadUploadContext.Current.UploadedFiles instead.

    We are about to release the RadControls for ASP.NET Ajax Q2 2008 package, where this model is changed and your code should work without a problem. I suggest that you upgrade to the new version, as it provides IIS7 Integrated mode compatibility and Safari support for the progress area in addition to the changed file processing model. The release is scheduled for later today.

    Kind regards,
    Erjan Gavalji
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. David S
    David S avatar
    11 posts
    Member since:
    May 2008

    Posted 23 Jul 2008 Link to this post

    Hi Erjan,

    Thank you for the answer.  I tried adding the RadUploadContext.Current.UploadedFiles to the function I copied however it did not work.

    Are there any samples that I can reference to achieve this?

    Thanks,
    David
  4. Answer
    Erjan Gavalji
    Admin
    Erjan Gavalji avatar
    1455 posts

    Posted 24 Jul 2008 Link to this post

    Hi David,

    Please, find attached a small sample for that.

    Please note, that the new version of RadUpload does not support this syntax for <asp:FileInput> controls anymore. This comes because of the simplified model of the control operation, which leaves the Request.Files collection intact.

    Kind regards,
    Erjan Gavalji
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top