Hello,
I am using the WiseJ Uploader to be able to upload files from the client machine to the server.
After the files are uploaded, some of the files are corrupt and cannot be opened. For example with images.
Here is my code, basically got it from here: https://wisej.com/support/question/vb-net-example-function-upload
I have 2 questions regarding working with the Uploader Control.
1: Corrupted Files
Private Sub Upload1_Uploaded(sender As Object, e As UploadedEventArgs) Handles Upload1.Uploaded
LoadFiles(e.Files)
End SubPrivate Sub LoadFiles(files As HttpFileCollection)
If files Is Nothing Then ReturnIf files.Count >= 1 Then
For i As Integer = 0 To files.Count – 1
ListBox1.Items.Add(files(i).FileName)
Dim fileStream = File.Create(“P:\Upload Test\” + files(i).FileName)
files(i).InputStream.Seek(i, SeekOrigin.Begin)
files(i).InputStream.CopyTo(fileStream)
fileStream.Close()
Next
End If
End Sub
Question 2:
If the client selects 1 file to upload, that gets sent to the HttpFileCollection.
If they select another file, the HttpFileCollection is overwritten. How can I keep it “alive” and just keep adding in files?
Hi, Dade!
Try:
Private Sub Upload1_Uploaded(sender As Object, e As UploadedEventArgs) Handles Upload1.Uploaded
Dim I As Integer
For I = 0 To e.Files.Count – 1
e.Files(I).SaveAs(“FILE”)
Next
End Sub
Best regards,
Ulisses.