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

How to Clear Rad Upload Files after Uploading

7 Answers 340 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Munendra
Top achievements
Rank 1
Munendra asked on 22 Sep 2010, 01:31 PM
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

7 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 22 Sep 2010, 02:18 PM
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.
0
Munendra
Top achievements
Rank 1
answered on 22 Sep 2010, 02:31 PM
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
0
Genady Sergeev
Telerik team
answered on 24 Sep 2010, 03:48 PM
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
0
Cliff Gibson
Top achievements
Rank 1
answered on 18 Nov 2010, 11:51 AM
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
0
Cori
Top achievements
Rank 2
answered on 18 Nov 2010, 02:33 PM
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.
0
Cliff Gibson
Top achievements
Rank 1
answered on 18 Nov 2010, 04:53 PM
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
0
Cori
Top achievements
Rank 2
answered on 18 Nov 2010, 06:30 PM
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.
Tags
Upload (Obsolete)
Asked by
Munendra
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Munendra
Top achievements
Rank 1
Genady Sergeev
Telerik team
Cliff Gibson
Top achievements
Rank 1
Share this question
or