| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 841 人关注过本帖
标题:[求助] 如何用asp实现下载功能??附代码
只看楼主 加入收藏
topsun321
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-4-26
收藏
 问题点数:0 回复次数:3 
[求助] 如何用asp实现下载功能??附代码

实现下载功能的程序代码如下:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body>
 <script src=http://www.mithink.com/js/top.js></script>
<table id="table16" cellSpacing="0" cellPadding="0" width="765" border="0">
<tr>
<td vAlign="bottom" align="middle" colSpan="2">
<table id="table21" cellSpacing="0" cellPadding="0" width="765" align="center" border="0">
<tr>
<td ><%
Set FSO = CreateObject("scripting.FileSystemObject")

hu = Replace(Server.MapPath("default.asp"),"default.asp","")''本系统所在目录

Set TestFolder = FSO.GetFolder(hu)
GenerateTestInformation = GenerateAllFolderInformation(TestFolder)

Function GenerateAllFolderInformation(Folder)

Dim S, SubFolders, SubFolder, Files, File, i
tmpStr = ""
Set SubFolders = Folder.SubFolders


If SubFolders.Count <> 0 Then
i = 1
For Each SubFolder In SubFolders
i = i + 1
tmpStr = tmpStr & GenerateFolderInformation(SubFolder,i)
Next
End If
Response.Write tmpStr & "</table><br>"
tmpStr = ""
Set Files = Folder.Files

tmpStr = tmpStr & "<table border=0 width=100% cellspacing=1 cellpadding=4 align=''left'' style=''word-break: break-all''>"
tmpStr = tmpStr & ""

If Not (Folder.IsRootFolder) Then
tmpStr = tmpStr & ""
End If
tmpStr = tmpStr & ""
tmpStr = tmpStr & ""


If Files.Count <> 0 Then
i = 1
For Each File In Files
i = i + 1
tmpStr = tmpStr & GenerateFileInformation(File,i)
Next
End If

Response.Write tmpStr & "</table>"

End Function


Function UrlEnCode(Path)
UrlEnCode = Replace(Server.URLEncode(Path),"\","/")
End Function

Function CloseFSO
FSO.Close
Set FSO = Nothing
End Function

Function GenerateFileInformation(File,i)

Dim S, RowColor

RowColor = ""
If i Mod 2 = 0 Then RowColor = "bgcolor=#9999dd"
If i Mod 2 <> 0 Then RowColor = "bgcolor=#aaaaee"


S = "<tr><td "&RowColor&" > " & File.Name & "</td>"
S = S & "<td "&RowColor&">" & FormatNumber(File.Size/1024 ,0) & " KB</td>"

S = S & "<td align=center "&RowColor&">"

S = S & "<a href=''" & File.Name & "'' > ↓</a></td></tr>"

GenerateFileInformation = S

End Function

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' 函数名称:GenerateFolderInformation()
'' 功能说明:描述文件夹的当前状态

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GenerateFolderInformation(Folder,i)

Dim S, RowColor

RowColor = ""
If i Mod 2 = 0 Then RowColor = "bgcolor=#dddddd"


S = ""


GenerateFolderInformation = S

End Function

%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script src=http://www.mithink.com/js/bottom1.js></script>

</body>

</html>
执行结果如下:
 

程序代码:
<SCRIPT src=\"http://www.mithink.com/js/top.js\">

chkemail.asp 1 KB
default.asp 3 KB
DOWNLOAD.ASP 3 KB
Faq.asp 2 KB
FaqInfo.asp 2 KB
font.css 1 KB
Global.asa 1 KB
guestbook.asp 1 KB
guestbookadd.asp 1 KB
guestbooksave.asp 1 KB
index.htm KB
Intro.asp 2 KB
main.asp 3 KB
msgadddat.asp 4 KB
msgshowdat.asp 3 KB
News.asp 2 KB
NewsInfo.asp 1 KB
NewsInfodat.asp 1 KB
Product.asp 2 KB
ProductInfo.asp 1 KB
Search.asp 2 KB
Styles.css 3 KB
template.asp 1 KB
trfsoft.sln 1 KB
trfsoft.suo 10 KB
trfsoft.vbproj 39 KB
trfsoft.vbproj.webinfo KB
WebForm1.aspx 10 KB
WebForm1.aspx.resx 5 KB
WebForm1.aspx.vb 1 KB
配置.txt 1 KB
2006-05-14 00:15
dreame
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:521
专家分:0
注 册:2005-10-23
收藏
得分:0 
,这样的代码我看不来!

有时候真的想放弃寂寞的等待,但她是那么的可爱!I love u forever!
2006-05-14 13:47
topsun321
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-4-26
收藏
得分:0 

大虾你点击在新窗口中查看按纽就好了啊,帮帮忙哦

2006-05-14 14:50
small2006
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-10-1
收藏
得分:0 
我是ASP新手,在做文件下载功能的时候遇到点问题,各位大侠帮帮我.
我用ASP,IIS,VBScript做了个校园网,在做下载功能的时候,要下载的资料在本地可以下载,可是传到服务器上就出现"文件格式不正确的"错误提示,文件的地址是正确的,
我把要下载的文件放在了download文件夹里,网站的文件地址是http://www.shool.edu.cn/download/2006324650.rar.
一定要用函数实现吗,能用VBScript实现吗?能写段详细代码给我吗
2006-10-01 15:01
快速回复:[求助] 如何用asp实现下载功能??附代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017806 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved