文件上传
刚到这来感觉还不错 把我的东西分享了 不知道这里面有没有?
< html>
< head>
< 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();
}
}
}
< /head>
< body>
HtmlInputFile Sample
Select File to Upload:
Save as filename (no path): < input id="Text1" type="text" runat="server">
< span id=Span1 style="font: 8pt verdana;" runat="server" />
< input type=button id="Button1" value="Upload"
runat="server">
< /form>
< /body>
< /html>