<script language="c#" runat="server">
void Button1_Click(object Source, EventArgs e) {
if (Text1.Value == "") {
Span1.InnerHtml = "Error: you must enter a file name";
return;
}
if (File1.PostedFile != null) {
try {
File1.PostedFile.SaveAs("c://temp//"+Text1.Value);
Span1.InnerHtml = "File uploaded successfully to c://temp//"+Text1.Value+" on the web server";
}
catch (Exception exc) {
Span1.InnerHtml = "Error saving file c://temp//"+Text1.Value+""+ exc.ToString();
}
}
}
void Page_Load(object sender, System.EventArgs e){
Span1.InnerHtml="";
}
</script>
<html>
<body>
HtmlInputFile Sample
<form enctype="multipart/form-data" runat="server">
Select File to Upload: <input id="File1" type=file runat="server">
Save as filename : <input id="Text1" type="text" runat="server">
<span id=Span1 style="font: 8pt verdana;" runat="server" />
<input type=button id="Button1" value="Upload" OnServerClick="Button1_Click" runat="server">
</form>
</body>
</html>