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

how to auto remove file if user close browser?

4 Answers 240 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
AUK
Top achievements
Rank 1
AUK asked on 05 Aug 2013, 09:25 AM
AsyncUpload is really come in handy, however I have a question which I don't know how to deal with:

I have a page with AsyncUpload control and other normal text fields for user to update/insert a article with attachment, and I only want to save file after user click 'Save' button (so not only for saving file but other text fields as well), however the attachment is uploaded asynchronously, so a file is uploaded before user click 'Save' button, so my questions is how to remove the file if user decide not to save page or even close browser ?

Many thanks!

4 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 07 Aug 2013, 11:17 AM
Hi,

The best way to handle this scenario is to use the default RadAsyncUpload configuration. It firsts upload files into the temporary folder and then on postback (clicking Save button) moves uploaded files from temporary to the target folder. Finally, all processed temporary files are deleted. Rest of the files that are not processed are cleared automatically after a set amount of time defined by the TemporaryFileExpiration property. Default value is 4 hours.

Regards,
Hristo Valyavicharski
Telerik
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 the blog feed now.
0
AUK
Top achievements
Rank 1
answered on 08 Aug 2013, 02:58 AM
Hello, many thanks to your prompt answer, now I totally get it!
0
Anu TM
Top achievements
Rank 1
answered on 08 Aug 2013, 06:15 PM
hi

"Finally, all processed temporary files are deleted". Does that mean the files that are saved are immediately deleted and those files which remains unprocessed will remain for 4 hours?

Thankyou
Anu.
0
Shinu
Top achievements
Rank 2
answered on 09 Aug 2013, 03:50 AM
Hi Anu,

The uploaded files are deleted immediately after the FileUploaded event has been fired. The rest of the files which are not uploaded or unprocessed will remain in the Temporary Folder for a period of 4 hours by default and the .NET framework will automatically delete them once the TemporaryFileExpiration duration is elapsed.

There is only a rare chance for the CacheDependency to leave the files from getting deleted such as the server is rebooted unexpectedly (In this case Shutting down the application pool is enough to remove any leftover files) or you accessed the FileSystem and didn't dispose it.

Thanks,
Shinu.
Tags
AsyncUpload
Asked by
AUK
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
AUK
Top achievements
Rank 1
Anu TM
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or