Does anyone know how to do FileUpload in asp.net 1.1. My current code works for 2.0 but I need to do this for 1.1. I know that FileUpload.HasFile doesn't work.Here is my code:

<%@ Page Language="vb" AutoEventWireup="false" Inherits="Promethius.PCMSPro.UploadFile" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script runat="server">  
  Protected Sub cmdUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs)   
        If Me.File1.PostedFile.ContentLength > "" Then
  
            Me.File1.PostedFile.SaveAs(Server.MapPath("~/Upload/" & Me.File1.PostedFile.FileName))
            Me.ltOne.Text = "File Uploaded Successfully"
        End If
  End Sub   
  
</script>  
<HTML>
	<HEAD>
		<TITLE>Upload File</TITLE>
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<meta http-equiv="Content-Language" content="en-us">
		<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
	</HEAD>
	<body leftmargin="0" topmargin="0" bottommargin="0" rightmargin="0">
		<div id="global">
			<form enctype="multipart/form-data" runat="server">
				<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
					<tr>
						<td id="TitleArea" class="dialogTitle">
							<table border="0" cellpadding="0" cellspacing="0" width="100%">
								<tr>
									<td class="dialogTitle" bgcolor="#ecf0f4">
										<img src="../images/icons/prom24.gif" align="left"><b><font face="Tahoma" color="#425971">Upload 
												File</font></b></td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td id="mainCell" height="100%" valign="top">
							<font face="tahoma" size="1">&nbsp;</font>
							<div align="left" style="PADDING-LEFT:20px;PADDING-BOTTOM:20px;WIDTH:100%;PADDING-TOP:20px">
								<asp:Label id="lblMessage" runat="server"></asp:Label><BR>
								<BR>
								Select file to upload:<BR>
								<input id="File1" type="file" runat="server" NAME="File1" style="WIDTH: 328px; HEIGHT: 22px"
									size="35">
								<br>
								<br>
								File Location:
								<asp:DropDownList ID="FileLoc" Runat="server"></asp:DropDownList>
								&nbsp;</div>
							<INPUT id="control" type="hidden" name="control" runat="server">
						</td>
					</tr>
					<tr>
						<td class="dialogButtons">
							<table border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="100%" bgcolor="#ecf0f4">&nbsp;</td>
									<td nowrap>
										<asp:Button ID="cmdUpload" Runat="server" Text="Upload Document" OnClick="cmdUpload_Click"></asp:Button>
										<input type="button" value="Done" class="Button" onclick="window.close();">
										<br />
										<asp:Literal ID="ltOne" runat="server" />  
 
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</HTML>

Any ideas?

ummmm i think i can solve your problem following is the code
try it

<%-- The Web Form with the EncType property set to Multipart/Form-Data --%>
<form Method="Post" EncType="Multipart/Form-Data" RunAt="Server">

   <%-- The File upload Html control --%>
   Choose Your File  To Upload <BR>
   <Input ID="MyFile" Type="File" RunAt="Server">
   <BR>

   <%-- A button - when clicked the form is submitted and the
            Upload_Click event handler is fired... --%>
   <Input Type="Submit" Value="Upload" 
             OnServerClick="Upload_Click" RunAt="Server">

   ...
</form>

The different attributes of HtmlInputFile control could be as follows:

<Input
   Type="File"
   RunAt="Server"
   ID="Specify an ID"
   Accept="Specify MIMEencodings"
   MaxLength="Specify maximum length of file path"
   Size="Specify width of textbox of the control" >

 
   
   Sub Upload_Click(Sender as Object, e as EventArgs)

  ' Display properties of the uploaded file
  FileName.InnerHtml = MyFile.PostedFile.FileName
  FileContent.InnerHtml = MyFile.PostedFile.ContentType 
  FileSize.InnerHtml = MyFile.PostedFile.ContentLength
  UploadDetails.visible = True

  'Grab the file name from its fully qualified path at client 
  Dim strFileName as string = MyFile.PostedFile.FileName
 
  ' only the attched file name not its path
  Dim c as string = System.IO.Path.GetFileName(strFileName)

  'Save uploaded file to server at C:\ServerFolder\
  Try 
    MyFile.PostedFile.SaveAs("C:\ServerFolder\" + c)
    Span1.InnerHtml = "Your File Uploaded Sucessfully at server as: " & _
                      "C:\ServerFolder\" & c
  Catch Exp as exception
    Span1.InnerHtml = "An Error occured. Please check the attached  file"
    UploadDetails.visible = false
    Span2.visible=false
  End Try
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.