PeOfEo
12-12-2003, 07:30 PM
I wrote this as a simple demonstration for another person and decided to post it here
<%@ Page Language="VB" Debug="true"%>
<script runat="server">
Sub uploadit (Sender as Object, e as EventArgs)
Dim strFileName as string
strFileName = theFile.PostedFile.FileName
Dim theFileName as string = System.IO.Path.GetFileName(strFileName)
Try
theFile.PostedFile.SaveAs("C:\intetpub\wwwroot\" + theFileName) 'Be sure to change this path for your dir!
successful.visible= true
catch Exp as exception
woops.Visible = true
End Try
End Sub
</Script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Simple Upload form
</title>
</head>
<body>
<form method="Post" enctype="Multipart/Form-Data" runat="Server">
Select a file to upload:
<input id="theFile" type="File" runat="Server" size="30">
<br><br>
<input type="Submit" value="Upload" onserverclick="uploadit" runat="Server">
<asp:label id="successful" runat="server" visible="false">
Your upload was a sucesses!
</asp:label>
<asp:panel id="woops" runat="server" Visible="False">
Your File upload failed.
</asp:panel>
</form>
</body>
</html>
to see it in action go to http://quasi-ke.servebeer.com/files/ASP.NET_scripts/upload.aspx
I will allow the dir its in to show its contents and post it, hold on...
ok http://quasi-ke.servebeer.com/files/ASP.NET_scripts
<%@ Page Language="VB" Debug="true"%>
<script runat="server">
Sub uploadit (Sender as Object, e as EventArgs)
Dim strFileName as string
strFileName = theFile.PostedFile.FileName
Dim theFileName as string = System.IO.Path.GetFileName(strFileName)
Try
theFile.PostedFile.SaveAs("C:\intetpub\wwwroot\" + theFileName) 'Be sure to change this path for your dir!
successful.visible= true
catch Exp as exception
woops.Visible = true
End Try
End Sub
</Script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
Simple Upload form
</title>
</head>
<body>
<form method="Post" enctype="Multipart/Form-Data" runat="Server">
Select a file to upload:
<input id="theFile" type="File" runat="Server" size="30">
<br><br>
<input type="Submit" value="Upload" onserverclick="uploadit" runat="Server">
<asp:label id="successful" runat="server" visible="false">
Your upload was a sucesses!
</asp:label>
<asp:panel id="woops" runat="server" Visible="False">
Your File upload failed.
</asp:panel>
</form>
</body>
</html>
to see it in action go to http://quasi-ke.servebeer.com/files/ASP.NET_scripts/upload.aspx
I will allow the dir its in to show its contents and post it, hold on...
ok http://quasi-ke.servebeer.com/files/ASP.NET_scripts