我在ASP下用过组件的上传下载,你要是想知道ASP。NET怎么实现,这里的帖子很多,你搜索帖子,用关键字“上传下载”。应该很多,前一段时间还有连载呢!
解决方案 »
- 关于网页提取操作方法推荐
- 郁闷!Asp.net页面调用dll,开发环境没问题,放到IIS7.0上就出错,请高手赐教!
- SqlTransaction 已完成;它再也无法使用
- 如何将DataGrid中的数据导出为excel文件?
- 在框架页面中如何个按钮设置快捷键!?
- 一夜未睡,这个正则搞不定。
- asp.net中的textbox好像没有onBlur事件,要实现这功能,该怎么办〉
- Nhibernate 实体对象更新后关联该对象的实体相关属性没有更新
- 程序员成长最危险的时刻(怎样成为优秀的软件人才)!?
- 怎样通过点击button,让datagrid增加一行!!!!!
- Visual Studio.NET 已检测到指定的Web服务器运行的不是ASP.NET1.1版.你将无法运行ASP.NET Web应用程序或服务.
- JS中的escape和unescape相当与ASPX中的什么?
//得到文件的路径
string strFile = this.txtFile.PostedFile.FileName.Trim();
//设置唯一的文件名
strFile.Substring(index,strFile.Length-index);
//指定文件要保存到的虚拟路径
string strPath = Page.MapPath("/Realty/AptImg/");
txtFile.PostedFile.SaveAs(strPath + strFile);
----------------------------------------------------------------------------
<%@ Import Namespace="System.IO" %>
<html>
<head>
<script language="VB" runat="server"> Sub Button1_Click(sender As Object, e As EventArgs) If Text1.Value = "" Then
Span1.InnerHtml = "错误:必须输入一个文件名"
Return
End If If Not IsNothing(File1.PostedFile) Then
Dim filepath As String = Path.Combine(Path.GetTempPath(), Path.GetFileName(Text1.Value)) Try
File1.PostedFile.SaveAs(filepath)
Span1.InnerHtml = "文件成功上载到 Web 服务器上的 <b>" & filepath & "</b"
Catch Exc As Exception
Span1.InnerHtml = "保存文件时出错<b>" & filepath & "</b><br>" & Exc.ToString()
End Try
End If
End Sub </script></head>
<body> <h3><font face="宋体">HtmlInputFile 示例</font></h3> <form enctype="multipart/form-data" runat="server"> 选择要上载的文件:<input id="File1" type=file runat="server"> <p>
另存为文件名(无路径):<input id="Text1" type="text" runat="server"> <p>
<span id=Span1 style="font: 9pt 宋体;" runat="server" /> <p>
<input type=button id="Button1" value="上载" OnServerClick="Button1_Click" runat="server"> </form></body>
</html>