<!--#include file="dbconn.asp"-->
<%
function readfile(filename)
on error resume next
err.clear
'asp的一种校错方法
const forreading = 2
const create = false
dim fso
dim ts
dim filepath
dim thefile
dim content
'---------------操作地址
set fso=server.createobject("scripting.filesystemobject")
filepath=server.mappath("temp") ./记录本存放的文件夹
if err.number<>0 then
response.write "目录不存在"
response.end
end if
'filename="test.txt" ---------test.txt为你从数据库里读出的文件名
thefile=filepath&"/"&filename
set ts = fso.opentextfile(thefile,1)
do until ts.atendofstream
response.write (""&ts.readline&"")
response.write("<br>")
loop
set ts = nothing
set fso = nothing
end function
%>
<%
dim id
dim filename
id=6
set rs=server.createobject("adodb.recordset")
sql="select * from yuan where id="&id
rs.open sql,cn,1,1
filename=rs("fileload")
%>
<% readfile(filename) %>
申明:本教程内容由威凡网编辑整理并提供IT程序员分享学习,如文中有侵权行为,请与站长联系(QQ:254677821)!
|