Initiate Live Support Contact Numbers Raise a Support Ticket
Hosting Technical Support Options
 
dotnetted - the asp.net hosting specialists
the asp.net hosting specialists
no part of Host-It.co.uk
 
order .net hosting .net hosting packages frequently asked questions technical support hosting terms / aup contact dotnetted
 
half price .net web hosting
 
half price .net 4.0 hosting
99.99% uptime DreamWeaver
UK based servers Visual Studio .Net
UK bandwidth Classic ASP
ASP.NET 1.1 - 4.5 SQL Server
IIS 7 or IIS 8 Application isolation
 
  Technical Support
 
General Support
Domain Names
Default Documents
SSL Shared Cert
ASP 500 error message
Pre-installed Files
Changing .Net version
Publishing Your Site
Uploading with FTP
FrontPage/Visual Studio
Using DreamWeaver
E-Mail
Greylisting (important)
Setup pop3 and smtp
Using webmail
E-mail administration
Configure spam filters
Databases
Access Database
SQL Server
Scripting
ASP Mail Script
ASP Form To E-Mail
ASP Send Secure E-Mail
Other ASP Components
Session State for .NET
Send mail with .NET 1.1
Send mail with .NET 2+
Upload file using .NET
Contact
Contact tech support

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 run.

Just copy and paste the code into a file and save it to your account with an .aspx suffix.

<html>
<script language="VB" runat="server">
Sub File_Upload (Sender as Object, e as EventArgs)
Dim strFileName as string
strFileName = MyFile.PostedFile.FileName
Dim myFileName as string = System.IO.Path.GetFileName(strFileName)
Try
MyFile.PostedFile.SaveAs(Server.mappath("/") + myFileName)
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
End Try
End Sub
</Script>

<body>
<form method="Post" enctype="Multipart/Form-Data" runat="Server">
Choose a file to upload to the server:<br>
<input id="MyFile" type="File" runat="Server" size="25">
<p></p>
<input type="Submit" value="Upload" onserverclick="File_Upload" runat="Server"><P>
<asp:panel id="ThankYouMessage" runat="server" Visible="False">
Your File was sucessfull.<p>
File Name: <span id="FileName" runat="Server"/><br>
File Content: <span id="FileContent" runat="Server"/><br>
File Size: <span id="FileSize" runat="Server"/>bytes<br>
</asp:panel>
<asp:panel id="ErrorMessage" runat="server" Visible="False">
Your File was not sucessful.
</asp:panel>
</form>
</body>
</html>

   
 
 
order hosting   hosting packages   frequently asked questions   technical support   terms and conditions   contact dotnetted
Copyright © DotNetted - All Rights Reserved Prices are subject to VAT @ 20%