下载的问题?
<P><a href="http://superman/test/gongwen.exe">download</a>
</P>
只要是*.exe就下载不了,其他文件都行,用另存为不行,用
flashget下也不行,有以下提示,我是win2000 server family+IE6+sp3
Thu Sep 04 10:30:47 2003 正在连接 superman:80
Thu Sep 04 10:30:47 2003 正在连接 superman [IP=192.168.123.103:80]
Thu Sep 04 10:30:48 2003 已连接.
Thu Sep 04 10:30:48 2003 GET /test/gongwen.exe HTTP/1.1
Thu Sep 04 10:30:48 2003 Host: superman
Thu Sep 04 10:30:48 2003 Accept: */*
Thu Sep 04 10:30:48 2003 Referer: http://superman/test/
Thu Sep 04 10:30:48 2003 User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)
Thu Sep 04 10:30:48 2003 Pragma: no-cache
Thu Sep 04 10:30:48 2003 Cache-Control: no-cache
Thu Sep 04 10:30:48 2003 Connection: close
求教朋友们问题在哪?也许程序没问题,可能是ie设置有问题
问题点数:50、回复次数:5Top
1 楼ceocio(成都招聘.Net工程师,有意者请联系我)回复于 2003-09-04 10:59:11 得分 5
在你的IIS中:
设置一下http头--MIME类型,新建一个类型扩展名为EXE,类型为:application/octet-streamTop
2 楼chinesun(郑返)回复于 2003-09-04 11:15:25 得分 45
你可以这样写:
你写一个DL.asp文件,这个文件源码如下:
****************************************
<%
Response.Buffer = true
Response.Clear
'获取要下载的文件在服务器上的绝对位置
dlfile=trim(request("dlfile"))
If dlfile<>"" Then
fileurl=server.MapPath(dlfile)
Else
Response.end
End If
'创建Myfso,使用FSO组件
Set Myfso=Server.CreateObject("Scripting.FileSystemObject")
Set f=Myfso.getfile(fileurl) '定义FSO对象f
fsize=f.size '文件大小
fName=f.name '文件名字
Set f=Nothing '释放f
Set Myfso=Nothing '释放MyFso
'使用Adodb.Stream组件
Set MyStream = Server.CreateObject("ADODB.Stream")
MyStream.Open
MyStream.Type = 1
MyStream.LoadFromFile fileurl
'读取文件类型,让系统识别,以存为不同类型的文件。
Select Case lcase(Right(fName, 4))
Case ".exe"
ContentType = "application/octet-stream"
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".asp"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select
'下载
Response.AddHeader "Content-Disposition", "attachment; filename=" & fName
Response.AddHeader "Content-Length", fsize
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite MyStream.Read
Response.Flush
'释放MyStream
MyStream.Close
Set MyStream = Nothing
%>
********************************
然后你在要实现的页面中这样调用:
*****************************************
<a href="dl.asp?dlfile=gongwen.exe">gongwen.exe</a>
*****************************************
本源码程序可以下载各种文件,包括asp源码、mp3、htm、TXT等等。Top
3 楼chinesun(郑返)回复于 2003-09-04 11:16:26 得分 0
另外:你还原一下你的IE的设置看看Top
4 楼flyingding(将军)回复于 2003-09-04 11:53:17 得分 0
ceocio(MS Community Star)兄,我试验过没有用Top
5 楼flyingding(将军)回复于 2003-09-04 12:37:33 得分 0
谢谢 chinesun(石上) ,问题解决Top




