Advertisement
John4711

asp.net multiple files upload

Dec 31st, 2022
2,298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.69 KB | None | 0 0
  1. ' HTML form that allows file selection and submission
  2. <form action="upload.aspx" method="post" enctype="multipart/form-data">
  3.   <input type="file" name="files" multiple>
  4.   <input type="submit" value="Upload">
  5. </form>
  6.  
  7. ' ASP.NET page that handles the file upload
  8. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  9.   ' Check if the form was submitted
  10.   If Request.HttpMethod = "POST" Then
  11.     ' Process the uploaded files
  12.     For Each file As String In Request.Files
  13.       Dim postedFile As HttpPostedFile = Request.Files(file)
  14.       ' Save the file to the server
  15.       postedFile.SaveAs("C:\Uploads\" & postedFile.FileName)
  16.     Next
  17.   End If
  18. End Sub
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement