Link to home
Start Free TrialLog in
Avatar of ProgrammerAtAIMS

asked on uploading picture to a temporary folder

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:AsyncFileUpload" and on AsyncFileUpload_UploadedComplete I am saving the Image and showing it using this code :
 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                
                 Image.imageurl = strPath
                 Image.imageurl = Defaultpth
             End If
                 Session(ViewState("page_id") + "fileuploaded") = 1
         End If
    End If
 End Sub

Open in new window

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 folder that is cleared after a while automatically without having to clear it manually.
Thank you in advance
Avatar of ste5an
Flag of Germany image

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.
Avatar of ProgrammerAtAIMS


Hi ste5an,
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.
Avatar of Prakash Samariya
Prakash Samariya
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial