Web Site Creator Web Hosting Help
   Uploading files using ASP.NET

The following example demonstrates how to use the PostedFile property to initiate the utility that transfers the file to the server.

<SCRIPT language=VB runat="server">
   Sub Button1_Click(Source As Object, e As EventArgs)

      If Text1.Value = "" Then
         Span1.InnerHtml = "Error: you must enter a file name" Return
      End If

      If Not (File1.PostedFile Is Nothing) Then

            File1.PostedFile.SaveAs(("e:\userdirs\wwwroot\myusername" + Text1.Value))
            Span1.InnerHtml = "File uploaded successfully to <b>...\myusername" & _
               Text1.Value & "</b> on the Web server"
         Catch exc As Exception
            Span1.InnerHtml = "Error saving file <b>...\myusername" & _
               Text1.Value & "</b><br>" & exc.ToString()          End Try
      End If
   End Sub 'Button1_Click

<H3>HtmlInputFile Sample</H3>

<P class=heading>
<FORM encType=multipart/form-data runat="server">
Select File to Upload:
<INPUT id=File1 type=file maxLength=30 runat="server">
</P> <BR>

<P>Save as filename (nopath): <INPUT id=Text1 runat="server"><BR>

<P><SPAN id=Span1 style="FONT:8pt verdana" runat="server"><BR>
<P><INPUT id=Button1 type=button value=Upload runat="server" OnServerClick="Button1_Click">

Sign Up Now! Overview

Questions? Call sales at
1 (425) 974-4688
Or try our
Visit our Help Center where you can get simple and quick product support.
bulkregister.com   is an affiliate of   , a leading domain name services company.
Copyright © 1999-2019 BulkRegister. All rights reserved. Terms & Conditions | Privacy Policy | Abuse Policy