Temp file lost on postback

2 posts, 0 answers
  1. David Blok
    David Blok avatar
    42 posts
    Member since:
    Nov 2009

    Posted 10 Jul 2012 Link to this post

    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'.


  2. Bozhidar
    Admin
    Bozhidar avatar
    1187 posts

    Posted 12 Jul 2012 Link to this post

    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.
Back to Top