ProgrammerAtAIMS
asked on
asp.net uploading picture to a temporary folder
hi,
I have a web page where a user can upload a file or picture and if a picture I need to display it in an image field.
I am using an "ajaxToolkit:AsyncFileUplo ad" and on AsyncFileUpload_UploadedCo mplete I am saving the Image and showing it using this code :
My code is working fine but after a while this temp folder I created is getting very large and I need to clear it.
I need to know if there is a way to upload my file to a temporary asp.net folder that is cleared after a while automatically without having to clear it manually.
Thank you in advance
I have a web page where a user can upload a file or picture and if a picture I need to display it in an image field.
I am using an "ajaxToolkit:AsyncFileUplo
Protected Sub AsyncFileUpload_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs)
If e.State = AjaxControlToolkit.AsyncFileUploadState.Success Then
If AsyncFileUpload.HasFile Then
Dim filename As String = System.IO.Path.GetFileName(e.FileName)
Dim fileextension As String = IO.Path.GetExtension(AsyncFileUpload2.FileName)
Dim strPath As String = MapPath("~/temp/") + filename
If IsValidImage(fileextension) Then
AsyncFileUpload.SaveAs(strPath)
Image.imageurl = strPath
else
AsyncFileUpload.SaveAs(strPath)
Image.imageurl = Defaultpth
End If
Session(ViewState("page_id") + "fileuploaded") = 1
End If
End If
End Sub
My code is working fine but after a while this temp folder I created is getting very large and I need to clear it.
I need to know if there is a way to upload my file to a temporary asp.net folder that is cleared after a while automatically without having to clear it manually.
Thank you in advance
It strongly depends on your requirements here, But I would consider touching the files, when displayed. So you can delete files older than a certain time span.
ASKER
Hi ste5an,
what do you mean by touching the file? do you have any example on this?
what do you mean by touching the file? do you have any example on this?
hmm, basic IPC.. Touching means to change a files attribute(s). In this case the last access date can be a candidate, when no other process (e.g. AV) is reading those files. Otherwise you need to touch the last modified or created date.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.