不过,看到了另外一个报道,明白上次我写的不直接打开而是另存为的作用了吧,就是《钢铁之花》的pdf另存为啦。
其实这个小程序一会就做完了。
<%
call downloadFile(Request("path"))
function downloadFile(strFile)
strFilename = server.MapPath(strFile)
Response.Buffer = True
Response.Clear
Set s = Server.CreateObject("ADODB.Stream")
s.Open
s.Type = 1
on error resume next
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>")
Response.End
end if
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
Response.End
end if
Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite s.Read
Response.Flush
s.Close
Set s = Nothing
End Function
%>
<a href="UpLoadFile/down.asp?path=<%=rs("path")%>">点击下载</a>
function downloadFile(strFile)if left(strFile,1)="/" orleft(strFile,1)="\" orleft(strFile,2)=".." then response.end
为了修改网站的session失效时间,遇到到网上查找了一些资料。得知,Session.Timeout = 20(分钟)是写在Global.asa中的。再搜索Global.asa的时候,得到的文章就开始千篇一律了,几乎全部来自于cnbruce(布鲁斯狼)的博客。
我们已经知道Application和Session对象的OnStart、OnEnd事件的脚本,都必须是在 Global.asa 文件中声明的。那究竟Global.asa是什么样的一个文件?它的作用有何?又该如何运用呢?且听我慢慢道来。
首先.asa是文件后缀名,它是Active Server Application的首字母缩写。Global.asa文件可以管理在ASP应用中两个非常苛刻的对象:Application、Session。
它其实是一个可选文件,程序编写者可以在该文件中指定事件脚本,并声明具有会话和应用程序作用域的对象。该文件的内容不是用来给用户显示的,而是用来存储事件信息和由应用程序全局使用的对象。该文件必须存放在应用程序的根目录内。每个应用程序只能有一个Global.asa文件。
关于Global.asa文件最常见的错误概念是它能为一般的使用的函数和子程序用作书库。Global.asa文件仅能用于创建对象的引用和俘获启动,以及结束Application对象和Session对象。
Global.asa文件主要基于会话级事件被访问,在以下三种情况下被调用:
1,当Application_OnStart或Application_OnEnd事件被触发。
2,当Session_OnStart或Session_OnEnd事件被触发。
3,当引用一个在Global.asa文件里被实例化的对象(Object)。……
全文地址:http://www.cnbruce.com/blog/showlog.asp?cat_id=26&log_id=419
他们抄袭的时候,什么也没有改变。包括“response.redirect("htp://www.cnbruce.com/")” 里面的网址错误也照抄不误,太没有技术含量了!
不过对于他这篇文章谈到的在线人数统计,有一个退出的页面exit.asp用到的session.Abandon(),我加到自己的退出页面里却始终无效。也就是说,在点击了退出的时候,人数并没有减少。实在想不通为什么。有没有高手路过?请教一下。