📄 htmlinputfile.aspx
字号:
<html>
<font face="宋体" size="0">
<head>
<script language="VB" runat="server">
Sub Button1_click(sender As Object,e As EventArgs)
'判断Text,Value的值是否为空
If Text1.Value=" " Then
Span1.InnerHtml="错误:必须输入文件名!"
Return
End if
If Not IsNothing(File1.PostedFile) Then
Try
File1.PostedFile.SaveAs("d:\asp.net\samples"+Text1.Value)
Span1.InnerHtml="文件成功传送到d:\asp.net\samples" & Text1.Value & "</b>"
Catch exc As Exception
Span1.InnerHtml="文件传送失败"
End Try
End If
End Sub
</script>
<title>HtmlInputFile举例</title>
</head>
<body>
<h3>
<font face="宋体" size="-1">HtmlInputFile 举例</font>
</h3>
<form enctyte="multipart/form-data" runat="server">
<font face="宋体" size="-1">
<--!布置HtmlInputFile控件-->
选择上传文件:
</font>
<input id="File1"
type=file
runat="server"
>
<p>
<font face="宋体" size="-1">
存储时的文件名:
</font>
<input id="Text1"
type="text"
runat="server"
>
<p>
<span id=Span1
style="font:12pt 宋体;"
runat="server"
/>
<p>
<input type=button
id="button1"
value="上传"
OnServerClick="Button1_Click"
runat="server"
>
</script>
</form>
</body>
</font>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -