File Uploading in ASP.NET (VB.net) : File Upload « Components « ASP.Net






File Uploading in ASP.NET (VB.net)

<%@ Page Language="vb" %>
<html>
   <head>
      <title>File Uploading in ASP.NET</title>
   <script runat="server">
      Sub UploadBtn_Click(Sender as Object, e as EventArgs)
         If InStr(Request.ContentType, "multipart/form-data") Then
            Dim Counter1 As Integer
            Dim Keys() As String
            Dim Files As HttpFileCollection
 
            Files = Request.Files

            Keys = Files.AllKeys
            For Counter1 = 0 To Keys.GetUpperBound(0)
               Response.Write("File ID: " & Keys(Counter1) & "<br>")
               Response.Write("File Name/Path: " & Files(Counter1).FileName & "<br>")
            Next Counter1
         Else
            Response.Write("No files uploaded, or wrong content type!")
         End If
      End Sub
   </script>
   </head>
<body>

<form id="UploadForm" action="retrieveFiles.aspx" method="post" enctype="multipart/form-data" runat="server">

   Select File To Upload to Server: 
   <br>
   <input id="MyFile" type="file" runat="server">
   <br>
   <input id="MyFile2" type="file" runat="server">
   <br>
   <input type="submit" value="Upload!" onserverclick="UploadBtn_Click" runat="server" id="Submit1">

</form>
</body>
</html>


<%-- retrieveFiles.aspx

<%@ Page Language="vb" %>
<html>
   <head>
      <title>File Uploading in ASP.NET</title>
   <script runat="server">
      Sub Page_Load()
         If InStr(Request.ContentType, "multipart/form-data") Then
            Dim Counter1 As Integer
            Dim Keys() As String
            Dim Files As HttpFileCollection
 

            Files = Request.Files

            Keys = Files.AllKeys
            For Counter1 = 0 To Keys.GetUpperBound(0)
               Response.Write("File ID: " & Keys(Counter1) & "<br>")
               Response.Write("File Name/Path: " & Files(Counter1).FileName & "<br>")
            Next Counter1
         Else
            Response.Write("No files uploaded, or wrong content type!")
         End If
      End Sub
   </script>
   </head>
<body>
<br>
</body>
</html>

--%>
           
       








Related examples in the same category

1.Upload File control (C#)
2.File Upload Demo (C#)
3.Uploading Files with the HTML Input File Control (VB.net)
4.Upload file to the server (VB.net)