Deleted files still upload

10 posts, 0 answers
  1. Jason Potter
    Jason Potter avatar
    10 posts
    Member since:
    Sep 2006

    Posted 15 May 2010 Link to this post

    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
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 17 May 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jason Potter
    Jason Potter avatar
    10 posts
    Member since:
    Sep 2006

    Posted 17 May 2010 Link to this post

    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
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 19 May 2010 Link to this post

    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.
  6. Robert Verderber
    Robert Verderber avatar
    33 posts
    Member since:
    Aug 2005

    Posted 22 May 2010 Link to this post

    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?

  7. Ross Barbieri
    Ross Barbieri avatar
    15 posts
    Member since:
    Jan 2010

    Posted 22 May 2010 Link to this post

    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.
  8. Ross Barbieri
    Ross Barbieri avatar
    15 posts
    Member since:
    Jan 2010

    Posted 25 May 2010 Link to this post

    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.
  9. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 26 May 2010 Link to this post

    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.
  10. Akinola
    Akinola avatar
    4 posts
    Member since:
    Mar 2012

    Posted 23 Jul 2012 Link to this post

    Hey Robert,

    Did you get past this issue? I have the same problem now....
  11. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 25 Jul 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017