This is a migrated thread and some comments may be shown as answers.

Progress Area

3 Answers 102 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
David S
Top achievements
Rank 1
David S asked on 22 Jul 2008, 08:57 PM
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

3 Answers, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 23 Jul 2008, 07:31 AM
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
0
David S
Top achievements
Rank 1
answered on 23 Jul 2008, 03:48 PM
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
0
Accepted
Erjan Gavalji
Telerik team
answered on 24 Jul 2008, 12:19 PM
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.
Tags
Upload (Obsolete)
Asked by
David S
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
David S
Top achievements
Rank 1
Share this question
or