<%--
upload.aspx
这是一个上传文件,从中我们可以看出asp.net的优势,以前需要控件才能完成的程序,现在只需要几行代码就可以轻松完成。
飞鹰编写,www.aspcool.com所有,转载时请保留此信息。
--%>
<%@ import namespace="system.io" %>
<%@ page language="c#" debug="true" codepage="936"%>
<html>
<head>
<title>文件上传,aspcool.com </title>
<script language="c#" runat="server">
public void uploadfile(object sender , eventargs e)
{
if(myfile.postedfile!=null)
{
//定义一些变量
string nam = myfile.postedfile.filename ;
int i= nam.lastindexof("\\") ;
string newnm =nam.substring(i) ;
//改变下面的“c:\\"到你想要保存的地址。
myfile.postedfile.saveas("c:\\"+newnm) ;
//取得上传文件的各种属性。
fname.text=myfile.postedfile.filename;
fenc.text=myfile.postedfile.contenttype ;
fsize.text=myfile.postedfile.contentlength.tostring();
}
}
</script>
</head>
<body>
<center>
<h3> 文件上传演示,飞鹰制作 </h3>
<form id="uploderform" method="post" action="upload.aspx" enctype="multipart/form-data" runat="server" >
<table border="1" cellspacing="0" cellpadding="0" >
<tr> <td><h5>选择文件</h5></td</tr>
<tr><td>
<input type="file" id="myfile" runat="server" >
</td></tr>
<tr><td>
<input type="button" value="upload" onserverclick="uploadfile" runat="server" >
</td></tr>
</table>
</form>
<br>
<br>
<table border="1" cellspacing="0">
<tr><td><b>文件资料</b></td>
<td> </td>
</tr>
<tr>
<td>文件名称 :</td>
<td><asp:label id="fname" text="" runat="server" /></td></tr>
<tr>
<td>文件类型 :</td>
<td><asp:label id="fenc" runat="server" /></td></tr>
<tr>
<td>文件大小 :(in bytes)</td>
<td><asp:label id="fsize" runat="server" /></td></tr>
</table>
<br>
<br>
<br>
<h5>你可以从 <a href="http://www.aspcool.com/download">http://www.aspcool.com/download</a> 下载该程序.我们将给您提供更多的其它程序。如果有什么意见请到我的<a href="http://www.chaxiu.com/club/right.php?boardid=7&page=1">asp论坛</a>来讨论。</h5>
</center>
</body>
</html>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器