• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

使用asp实现支持附件的邮件系统(三)

发布: 2007-7-14 19:37 | 作者: 佚名    | 来源: 网络转载     | 查看: 15次 | 进入软件测试论坛讨论

领测软件测试网 最后,我们来讲讲如何把内容从数据库中读出来,内容有这么几类,一类是浏览器上可以显示的,例如*.htm,一类是需要下载的,例如*.exe,还有一种是浏览器可以显示但是不能够让他显示的,例如*.asp,请看代码:

<%
Response.Buffer= true
Response.Clear

function getname(oriname)
thename=oriname
do while instr(thename,"/")>0
thename=mid(thename,instr(thename,"/")+1)
loop
do while instr(thename,"\")>0
thename=mid(thename,instr(thename,"\")+1)
loop
getname=thename

end function

function canexec(thechar)
if instr(thechar,".asp")>0 then
canexec=false
exit function
end if
if instr(thechar,".asa")>0 then
canexec=false
exit function
end if
if instr(thechar,".aspx")>0 then
canexec=false
exit function
end if
if instr(thechar,".asax")>0 then
canexec=false
exit function
end if
canexec=true
end function
mailID=request("mailID")
se=request("se")
if se<>1 and se<>2 and se<>3 then
response.end
end if
Set conn=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
conn.open "DSN=;UID=;PWD="
sql="select * from t_mail where ((geterempl like '%"&session("myid")&"%' or deleempl like '%"&session("myid")&"%' or receempl like '%"&session("myid")&"%' ) and (not deleverempl like '%"&session("myid")&"%')) and mailid='"&mailid&"' "
rs.open sql,conn,3,3
if rs.eof or rs.bof then
response.end
end if
if rs("filecontenttype_"&trim(se))<>"text/plain" or (not canexec(getname(trim(rs("filename_"&trim(se)))))) then
Response.ContentType = rs("FileContentType_"&trim(se))
end if


'Response.AddHeader "content-type","application/x-msdownload"

if instr(response.contenttype,"application")>0 then
response.AddHeader "Content-Disposition","attachment;filename="&getname(trim(rs("filename_"&trim(se))))
end if
Response.BinaryWrite rs("FileContent_"&trim(se))
rs.close
set rs=Nothing
conn.close
set conn=nothing
%>

文章到这里就结束了,至于邮件数据库的数据结构大家根据代码自己琢磨吧!


延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网