关于文件下载

<%
function dl(f,n)
 
 on error resume next
 Dim S
 Set S=CreateObject("Adodb.Stream")
 S.Mode=3
 S.Type=1
 S.Open
 S.LoadFromFile(server.mappath(f))
 if Err.Number>0 then
  Response.Status="404"
 else
  Response.ContentType="application/*"
  Response.AddHeader "Content-Disposition:","attachment; filename=" & n
  Range=Mid(Request.ServerVariables("HTTP_RANGE"),7)
  if Range="" then
   Response.BinaryWrite(S.Read)
  else
   'S.position=Clng(Split(Range,"-")(0))
   Response.BinaryWrite(S.Read)
  End if
 end if
 Response.End
end function

If request("action")="down" Then
   call dl(request("path"),"aa.gif")
End If

%>
<img src=index.gif>
<a href=?action=down&path=index.gif>点击下载此图片</a>

 

 

 

 

 

 

 

 

<SCRIPT language=JavaScript>
function aa(tt)
{
 var wp = window.open(tt.src,"","width=100,height=100");
 wp.document.execCommand("saveAs");
}
</SCRIPT>
<IMG onclick=aa(this) alt=单击保存 src="../face/0001.gif" border=0>

阅读更多
个人分类: ASP
上一篇利用VBScript及ADODB.Steam获取部分格式图象长宽
下一篇一个传输类
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭