How to Clear Rad Upload Files after Uploading

Thread is closed for posting
8 posts, 0 answers
  1. Munendra
    Munendra avatar
    2 posts
    Member since:
    Sep 2010

    Posted 22 Sep 2010 Link to this post

    Hi Telerik

    I am using RadUpload Control, I have problem that everytime I upload files, those files remain in uploadfiles method or array.
    I want to clear those previous files name once they uploded. when ever I upload one file and save file info into database then if I try to refresh the page then the file previously uploaded will be uploaded again.

    I want to delete uploaded files from memory. I mean to say How can I clear the Files from Rad upload memory or How to Clear RadControl Control after Successfully uploading the Files.

    Please Help!!!!

    Munendra Maheshwari
  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 22 Sep 2010 Link to this post

    When you say "refresh the page", what are you referring to? Are you doing reloading the page in a javascript call or are redirecting it back to itself.

    If you could explain how your refreshing the page so we can better understand your problem.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Munendra
    Munendra avatar
    2 posts
    Member since:
    Sep 2010

    Posted 22 Sep 2010 Link to this post

    Hi Gary,

    First of all thnx for the reply.

    Refreshing means Click on the button in front of URL Box.
    Suppose I click on that refresh button aftton after uploading the files, it basically insert the same files which were previously uploaded.
    So what I wanna do is just refresh the RadUpload control.

    Help is apreciable.

    Regards,
    Munendra Maheshwari
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 24 Sep 2010 Link to this post

    Hi Munendra,

    Pressing the refresh browser button will repeat the previous request, hence upload the previously selected. This is behavior that all browsers follow and it has nothing to do with RadUpload. As a workaround you can check whether the uploaded files do not already exist in the database before inserting them.

    Sincerely yours,
    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. Cliff Gibson
    Cliff Gibson avatar
    45 posts
    Member since:
    Oct 2009

    Posted 18 Nov 2010 Link to this post

    Hi, is there any way to remove the file once uploaded in the FileUploaded event...

     

    protected void AsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            byte[] photo = EM_Functions.GetFileBytes(e.File.InputStream);
            byte[] thumbnail = EM_Functions.ResizeImage(photo, 200);
            string fileType = EM_Functions.GetFileType(e.File.FileName);
            EM_Data.UploadPhoto(1, photo, thumbnail, e.File.FileName, fileType, photo.Length, "Title", "rhu01");
      
            //now delete the file        
        }

    As you can see above here is where I'm handling the file upload, but once in my database I would like to remove the particular file...

    Cheers
    Cliff
  7. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 18 Nov 2010 Link to this post

    Hello Cliff,

    If you don't set a TargetFolder for the upload control to save the file to, then there is no reason to delete the uploaded file, since it saves it in a temporary folder that removes the file automatically.

    I hope that helps.
  8. Cliff Gibson
    Cliff Gibson avatar
    45 posts
    Member since:
    Oct 2009

    Posted 18 Nov 2010 Link to this post

    Hi Cori

    I've set the timeout to a low value so the temp files get deleted pretty quickly, however if for any reason the user chooses to refresh the page the files get uploaded again.

    I understand I could check for duplicates during the upload to the server, however if there was a way to clear down the contents of the upload control this would be easier.

    Cheers
    Cliff
  9. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 18 Nov 2010 Link to this post

    Hello Cliff,

    You can't clear the upload control because, just like Genady said, that is how the browser works. If you refresh the page it will try and execute the command again.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017