<%@ Import Namespace=”System.IO” %>
<script language=”VB” runat=”server”>
Sub Page_Load(source as Object, e as EventArgs)
‘Has the form been submitted?
If Page.IsPostBack AND fupUpload.PostedFile <> Nothing Then
‘Save the file if it has a filename and exists...
If fupUpload.PostedFile.FileName.Trim().Length > 0 AND _
fupUpload.PostedFile.ContentLength > 0 then
Const strBaseDir as String = “C:\My Projects\Uploaded Files\”
Dim strFileName as String = _
File.GetFileNameFromPath(fupUpload.PostedFile.FileName)
fupUpload.PostedFile.SaveAs(strBaseDir & strFileName)
‘File has been saved!
lblResults.Text = “<hr><p>Your file, “ &
fupUpload.PostedFile.FileName & _
“, has been saved to the Web server!<br>” & _
“[<a href=””/Upload/” & strFileName & “””>View
File</a>]”
End If
Else
lblResults.Text = “<hr><p>Enter a filename to upload!”
End If
End Sub
</script>
<html>
<body>
<form runat=”server” EncType=”multipart/form-data”>
<h1>File Upload</h1>
<b>Select the file to upload:</b><br>
<input runat=”server” id=”fupUpload” type=”file” >
<p>
<asp:button id=”btnSubmit” runat=”server” Text=”Upload File” />
<p><asp:label runat=”server” id=”lblResults” />
</form>
</body>
</html>