请各位高手帮我解决一下asp的问题(我是.NET的):
用一个链接弹出保存文件的对话框:
具体:
我现在在文件的目录下遍历了所有的文件,并让所有文件显示出来了
代码如下:
<%
class getFldTree
Public Function getTree(ByVal sPath,ByVal iLevel)
Dim sRet
Dim oFs,oFld,oSubFld,oFile
Dim sFn,sMapPath
Dim imgFile
On Error Resume Next sRet = ""
Set oFs = CreateObject("Scripting.FileSystemObject")
sPath = Replace(sPath & "\","\\","\")
sMapPath = server.MapPath(sPath)
'response.write(sPath & "<br>")
'response.write(sMapPath & "<br>") Set oFld = oFs.GetFolder(sMapPath)
For Each oSubFld In oFld.subfolders
If Right(oSubFld.Name,6)=".files" _
Or oSubFld.Name="css" _
Or oSubFld.Name="js" _
Or Right(oSubFld.Name,6)="_files" Then
Else
If oSubFld.subfolders.Count > 0 Then
imgFile = "fld_hassub.png"
'response.write(oSubFld.Name & "=")
'response.write(oSubFld.subfolders.Count & "<br>")
Else
imgFile = "fld_nosub.png"
End If
sRet = sRet & "<div nowrap style='cursor:hand' onclick=fldClick('" & replace(replace(sPath,"\","\\") & oSubFld.Name," ","%20") & "',this)>" _
& "<img style='margin-bottom:-2px' src='images.files/" & imgFile & "' border=0 width='16' height='16'>" _
& M_ICON_BLANK & oSubFld.Name & "</div>"
End If
Next
Dim Exts,sFileExt,sURL
Set s = server.createobject("adodb.stream")
s.open
s.type = 1
For Each oFile In oFld.Files
Exts = Split(oFile.Name,".")
sFileExt = Exts(ubound(Exts)) If instr(1,M_FILTER_LIST,"," & sFileExt)=0 and instr(1,M_FILTER_LIST,"," & oFile.Name)=0 Then
imgFile = "images.files/ext_" & sFileExt & ".png"
If Not oFs.FileExists(Server.MapPath(imgFile)) Then
imgFile = "images.files/ext_unknow.png"
End If
If Instr(1,M_FILTER_CODE,"," & sFileExt) = 0 Then
sURL = sPath & oFile.Name 'Server.URLEncode()
Else
sURL = "/CodeHighlighter/showcode.aspx?filename=" & server.MapPath(sPath) & "\\" & oFile.Name End If
sRet = sRet & "<div nowrap><img style='margin-bottom:-2px' src='" _
& imgFile & "' border=0 width='16' height='16'>" _
& M_ICON_BLANK _
& "<span style='cursor:hand' " _
& "onClick=lnkClick('" _
& replace(replace(sURL,"\","\\")," ","%20") & "')>" _
& oFile.Name _
& "</span> <font color='gray'>"_
& oFile.datelastmodified _
&"</font> <a href='"_
&Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(oFile.Name _
&")'><font color='orange'>下载</font></a></div>"
End If
Next
getTree = sRet
End Function
end class
%>
在最后面便有一个下载的链接,我现在一点击链接,它文件就直接打开了,我现在不想直接打开,而是弹出保存文件的对话框,怎么办,就在上面的代码中实现,写具体点,不要告诉一些方法,我知道,就是不知道怎么加上去!!
很急的,请各位帮帮小女子,谢谢了!!
用一个链接弹出保存文件的对话框:
具体:
我现在在文件的目录下遍历了所有的文件,并让所有文件显示出来了
代码如下:
<%
class getFldTree
Public Function getTree(ByVal sPath,ByVal iLevel)
Dim sRet
Dim oFs,oFld,oSubFld,oFile
Dim sFn,sMapPath
Dim imgFile
On Error Resume Next sRet = ""
Set oFs = CreateObject("Scripting.FileSystemObject")
sPath = Replace(sPath & "\","\\","\")
sMapPath = server.MapPath(sPath)
'response.write(sPath & "<br>")
'response.write(sMapPath & "<br>") Set oFld = oFs.GetFolder(sMapPath)
For Each oSubFld In oFld.subfolders
If Right(oSubFld.Name,6)=".files" _
Or oSubFld.Name="css" _
Or oSubFld.Name="js" _
Or Right(oSubFld.Name,6)="_files" Then
Else
If oSubFld.subfolders.Count > 0 Then
imgFile = "fld_hassub.png"
'response.write(oSubFld.Name & "=")
'response.write(oSubFld.subfolders.Count & "<br>")
Else
imgFile = "fld_nosub.png"
End If
sRet = sRet & "<div nowrap style='cursor:hand' onclick=fldClick('" & replace(replace(sPath,"\","\\") & oSubFld.Name," ","%20") & "',this)>" _
& "<img style='margin-bottom:-2px' src='images.files/" & imgFile & "' border=0 width='16' height='16'>" _
& M_ICON_BLANK & oSubFld.Name & "</div>"
End If
Next
Dim Exts,sFileExt,sURL
Set s = server.createobject("adodb.stream")
s.open
s.type = 1
For Each oFile In oFld.Files
Exts = Split(oFile.Name,".")
sFileExt = Exts(ubound(Exts)) If instr(1,M_FILTER_LIST,"," & sFileExt)=0 and instr(1,M_FILTER_LIST,"," & oFile.Name)=0 Then
imgFile = "images.files/ext_" & sFileExt & ".png"
If Not oFs.FileExists(Server.MapPath(imgFile)) Then
imgFile = "images.files/ext_unknow.png"
End If
If Instr(1,M_FILTER_CODE,"," & sFileExt) = 0 Then
sURL = sPath & oFile.Name 'Server.URLEncode()
Else
sURL = "/CodeHighlighter/showcode.aspx?filename=" & server.MapPath(sPath) & "\\" & oFile.Name End If
sRet = sRet & "<div nowrap><img style='margin-bottom:-2px' src='" _
& imgFile & "' border=0 width='16' height='16'>" _
& M_ICON_BLANK _
& "<span style='cursor:hand' " _
& "onClick=lnkClick('" _
& replace(replace(sURL,"\","\\")," ","%20") & "')>" _
& oFile.Name _
& "</span> <font color='gray'>"_
& oFile.datelastmodified _
&"</font> <a href='"_
&Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(oFile.Name _
&")'><font color='orange'>下载</font></a></div>"
End If
Next
getTree = sRet
End Function
end class
%>
在最后面便有一个下载的链接,我现在一点击链接,它文件就直接打开了,我现在不想直接打开,而是弹出保存文件的对话框,怎么办,就在上面的代码中实现,写具体点,不要告诉一些方法,我知道,就是不知道怎么加上去!!
很急的,请各位帮帮小女子,谢谢了!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货