Upload file using .NET
With Classic ASP it was difficult to upload
files to your account via a web page without
the use of a third party component. This
has changed with the introduction of .NET
and it's now possible to easily upload files
with just a few lines of code.
The following script is a generic upload
script that uses an html form which allows
you to select a file on your local machine
and then upload it to the server - the file
will be uploaded to the some folder on the
server from which the upload script was
Just copy and paste the code into a file
and save it to your account with an .aspx
<script language="VB" runat="server">
Sub File_Upload (Sender as Object, e as
Dim strFileName as string
strFileName = MyFile.PostedFile.FileName
Dim myFileName as string = System.IO.Path.GetFileName(strFileName)
FileName.InnerHtml = MyFile.PostedFile.FileName
FileContent.InnerHtml = MyFile.PostedFile.ContentType
FileSize.InnerHtml = MyFile.PostedFile.ContentLength
ThankYouMessage.Visible = true
catch Exp as exception
ErrorMessage.Visible = true
<form method="Post" enctype="Multipart/Form-Data"
Choose a file to upload to the server:<br>
<input id="MyFile" type="File"
<input type="Submit" value="Upload"
Your File was sucessfull.<p>
File Name: <span id="FileName"
File Content: <span id="FileContent"
File Size: <span id="FileSize"
Your File was not sucessful.