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

Temp file lost on postback

1 Answer 150 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
David Blok
Top achievements
Rank 1
David Blok asked on 10 Jul 2012, 08:53 AM
Hi, i'm trying to upload some files and write them away.
But everytime i do a postback the files are gone, anyone have an idea what i'm doing wrong ?

Front end code
<telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" MultipleFileSelection="Automatic">
</telerik:RadAsyncUpload>


Backend
Protected Sub btnsaveimages_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsaveimages.Click
         If RadAsyncUpload1.UploadedFiles.Count > 0 Then
             For Each file As UploadedFile In RadAsyncUpload1.UploadedFiles
                 file.SaveAs("~/" + file.FileName)
              Next
         End If
     End Sub

Or on fileuploaded
Sub RadAsyncUpload1_FileUploaded(ByVal sender As Object, ByVal e As FileUploadedEventArgs) Handles RadAsyncUpload1.FileUploaded
 
        e.File.SaveAs(Server.MapPath("~/Upload/Images/ImgGallery/2/" + e.File.FileName), True)
 
    End Sub


I always get the following error: 
Could not find file '***********\App_Data\RadUploadTemp\1341910388330Lighthouse.jpg'.


1 Answer, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 12 Jul 2012, 02:56 PM
Hello David,

Are you using both handlers at the same time? The SaveAs() function of the uploaded file removes it from the temporary folder, so if you try to save it a second time, this error is expected. 

To get the RadAsyncUpload working properly you have to use either one of the two handlers, but not both at the same time.
 
All the best,
Bozhidar
the Telerik team
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 their blog feed now.
Tags
AsyncUpload
Asked by
David Blok
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or