my code works if i select only one file to upload.
but it will return error if i select more than one files.
<telerik:RadAsyncUpload runat="server" ID="AsyncUpload_Attachment" OnFileUploaded="AsyncUpload_Attachment_FileUploaded" PostbackTriggers="RadButton1" InitialFileInputsCount="1" MaxFileSize="10240000" MultipleFileSelection="Automatic"/> <telerik:RadButton runat="server" ID="RadButton1" Text="Submit your file"OnClick="RadButton1_Click" AutoPostBack="false" OnClientClicked="updatePictureAndInfo" Skin="Default" /> <script type="text/javascript"> //<![CDATA[ var $ = $telerik.$; function onClientFileUploaded(sender, args) { } function updatePictureAndInfo() { __doPostBack('RadButton1', ''); } //]]> </script>Code Behind
Protected Sub AsyncUpload_Attachment_FileUploaded(ByVal sender As Object, ByVal e As Telerik.Web.UI.FileUploadedEventArgs) If Me.AsyncUpload_Attachment.UploadedFiles.Count > 0 Then PopulateUploadedFilesList(AsyncUpload_Attachment) End IfEnd Sub
Private Sub PopulateUploadedFilesList(ByVal uf As RadAsyncUpload) Dim filePath As String = System.Configuration.ConfigurationManager.AppSettings("AttachmentPath").ToString() Dim fileName As String = "" Dim sessionid As Integer = 0 Dim dc As New dcLRDBDataContext If Not IsNothing(HttpContext.Current.Session("SessionID")) Then sessionid = HttpContext.Current.Session("SessionID").ToString ElseIf Not IsNothing(HttpContext.Current.Session("tmpSID")) Then sessionid = HttpContext.Current.Session("tmpSID").ToString Else Dim rnd As New Random() Dim tmpSID As Integer 'allow 10 digit only tmpSID = rnd.Next(1000, 9999) & DateTime.Now.Hour & DateTime.Now.Minute HttpContext.Current.Session("tmpSID") = tmpSID sessionid = tmpSID End If For Each file As UploadedFile In uf.UploadedFiles Dim uploadedFileInfo As New UploadedFileInfo(file) UploadedFiles.Add(uploadedFileInfo) Dim newRecord1 As New db_Attachment dc.db_Attachments.InsertOnSubmit(newRecord1) newRecord1.FileName = sessionid & "_" & file.FileName newRecord1.FileSize = file.ContentLength / 1024 newRecord1.UploadBy = HttpContext.Current.Session("UserID") newRecord1.UploadDate = DateTime.Now newRecord1.LastUpdatedOn = DateTime.Now newRecord1.LastUpdatedBy = HttpContext.Current.Session("UserID") dc.SubmitChanges() file.SaveAs(filePath & sessionid & "_" & file.FileName) Next dc.Dispose()End Subit return error when doing th "file.saveAs...." code