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

Deleted files still upload

9 Answers 271 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Jason Potter
Top achievements
Rank 1
Jason Potter asked on 16 May 2010, 12:38 AM
Hi There,

in the demo below:
http://demos.telerik.com/aspnet-ajax/upload/examples/async/webmail/defaultcs.aspx

If you select two files to be uploaded and then delete one by pressing the delete icon and then press send both files appear on the next page.  In my testing I have not been able to inform the Upload control to not process the deleted file.  So on postback the FileUploaded event gets fired and the upload control still has 2 files attached.

I understand that the files get uploaded to the temporary location but it would be good to have a property in the FileUploadedEventArgs for the file if it was deleted client side.

Any ideas on a work around would be greatly appreciated.

Regards
Jason

9 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 17 May 2010, 03:17 PM
Hello Jason Potter,

This is a bug in RadAsyncUpload. I have already logged it into our bug-tracking system and we will fix it in the near future. Meanwhile, the following workaround can be used, hook on the OnClientDeleting event of RadAsyncUpload and use the following code:

function deleting(sender, args) {
            var clientStateJson = sender.get_clientState();
 
            var clientState = Sys.Serialization.JavaScriptSerializer.deserialize(clientStateJson);
            Array.removeAt(clientState.uploadedFiles, args._rowIndex);
            sender.set_clientState(Sys.Serialization.JavaScriptSerializer.serialize(clientState));
        }


Best wishes,
Genady Sergeev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jason Potter
Top achievements
Rank 1
answered on 17 May 2010, 03:35 PM
Hi There,

Implement the code as suggested but it did not work as expected.

After uploading a file then deleting it and then uploading a different file, when you do a post back I get a file not found error when it gets to the using statement in the following code.  It works file if you just upload a single file.

protected void RadUpload1_FileUploaded(object sender, FileUploadedEventArgs e) 
    { 
        UploadedImage.Width = Unit.Pixel(250); 
        UploadedImage.Height = Unit.Pixel(200); 
 
 
        byte[] imageData; 
        using (Stream stream = e.File.InputStream) 
        { 
            imageData = new byte[e.File.ContentLength]; 
            stream.Read(imageData, 0, e.File.ContentLength); 
        } 
 
        UploadedImage.ResizeMode = Telerik.Web.UI.BinaryImageResizeMode.Fit; 
        UploadedImage.GenerateEmptyAlternateText = true
        UploadedImage.DataValue = imageData; 
    } 


Any ideas on how to avoid this.

Thanks
Jason
0
Genady Sergeev
Telerik team
answered on 19 May 2010, 12:39 PM
Hi Jason Potter,

It seems that it is not that easy to workaround the problem. I have raised the bug priority and we will fix it for the next week's latest internal build.

Kind regards,
Genady Sergeev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Robert Verderber
Top achievements
Rank 2
answered on 22 May 2010, 08:14 PM
I am having a problem and was wondering if it is related to the same issue. I am using the Ajax Avatar demo as a basis for what I want to accomplish. Every thing works fine with the first file I upload. When I try to upload another file the File_Uploaded event fires for both the first file and the second. A third file fires the event 3 times and so on.

if have implemented the function from the demo 

    //submit an ajax request to handle the file upload
            function fileUploaded(sender, args) {
                $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest();
                sender.deleteFileInputAt(0);
            }

and the workaround you posted above. Still get multiple events firing. I'm trying to get it to just post one file at a time. Same issue?

0
Ross Barbieri
Top achievements
Rank 1
answered on 23 May 2010, 04:21 AM
We are being affected by this bug.  We need to go to production with the fix by mid-June, and are not comfortable (as you have suggested we should not be) with going to production with an internal Rad build.  Do you have any date by which this bug fix will be released in an official build?

Thanks.
0
Ross Barbieri
Top achievements
Rank 1
answered on 25 May 2010, 02:26 PM
PS - I would like to add a note that in the scenario described in this thread, the temporary file supposedly-removed is not deleted from the server file system.  I have queried in a separate thread on this forum as to how one can delete temporary files in this and other scenarios where they are not being deleted by the Rad code.
0
Genady Sergeev
Telerik team
answered on 26 May 2010, 01:59 PM
Hello Ross Barbieri,

The official fix is going to be available with Q2 which is scheduler for the beginning of July. The good news are that we have managed to find out a working workaround and there is no need to use latest internal build. Here it is:

script type="text/javascript">
        function clientFileDeleting(sender, args) {
            args.set_cancel(true);
            var index = args.get_rowIndex();
            Array.removeAt(sender._uploadedFiles, index);
            sender.deleteFileInputAt(index, true);
            sender.updateClientState();
        }      
    </script>
 
    <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" TargetFolder="~/Documents"
         OnClientDeleting="clientFileDeleting">
    </telerik:RadAsyncUpload>


Please, take a look at the attached project for details.

All the best,
Genady Sergeev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Akinola
Top achievements
Rank 1
answered on 23 Jul 2012, 07:32 PM
Hey Robert,

Did you get past this issue? I have the same problem now....
0
Genady Sergeev
Telerik team
answered on 25 Jul 2012, 01:22 PM
Hi Jason,

The problem is resolved by now. What version of the AJAX suite are you using? If you are using the latest version and still there are problems please open  a support ticket and share more details regarding your scenario.

All the best,
Genady Sergeev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
AsyncUpload
Asked by
Jason Potter
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Jason Potter
Top achievements
Rank 1
Robert Verderber
Top achievements
Rank 2
Ross Barbieri
Top achievements
Rank 1
Akinola
Top achievements
Rank 1
Share this question
or