Duh.
The control appears as a texbox with a Browse... button. The following puts the control on the page and sets the file to be uploaded to directory C:\\rptsys on the server.
<asp:FileUpload ID="FileUpload1" runat="server" filename ="C:\\rptsys\" />
Added a button to initiate the upload and a label to display the result:
<asp:Button ID="Button1" runat="server" Text="UploadFile" onclick="Button1_Click" /> </div> <asp:Label ID="Label1" runat="server" Text="Label"Width="247px"></asp:Label>
I put together a simple UI:
The Browse button opens up a full choose file dialog window.
The backend code:
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
Label1.Text = "File Uploaded: " + FileUpload1.FileName;
FileUpload1.SaveAs(@"C:\temp\uploads\" +
FileUpload1.FileName);
}
else
{
Label1.Text = "No File Uploaded.";
}
}
After the file is transmitted, I display a "success" message.