asp编程提示ADODB.Stream 错误 '800a0bba' 文件无法被打开。 20
按下面的方法做,提示ADODB.Stream错误'800a0bba'文件无法被打开。/uploadimg.asp,行16。16行是这句话:objStream.LoadFr...
按下面的方法做,提示ADODB.Stream 错误 '800a0bba' 文件无法被打开。/uploadimg.asp,行 16 。16行是这句话:objStream.LoadFromFile file
具体的网页文件如下:
asp 文件上传 代码
文件1.上传界面文件 upload.htm
<html>
<head>
<meta
http-equiv="Content-Language" content="zh-cn">
<meta
http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>文件上传</title>
</head>
<body>
<form
method="POST" action="SaveFile.asp">
文件上传:<input type="file"
name="file" size="42"> <input type="submit" value="提交"
name="bb">
</form>
</body>
</html>
文件2.保存上传文件
SaveFile.asp
<%
dim file,filename,houzui
file =
Request.Form("file")
if file=""
then
response.write"<script>alert('请选择要上传的文件!');window.location.href='upload.htm';</script>"
else
houzui=mid(file,InStrRev(file,
"."))
if houzui=".gif" or houzui=".jpg" or houzui=".bmp" then
'允许上传的文件类型
filename=year(date) & month(date) & day(date) &
Hour(time) & minute(time) & second(time) & houzui
Set
objStream = Server.CreateObject("ADODB.Stream")
objStream.Type =
1
objStream.Open
objStream.LoadFromFile file
objStream.SaveToFile
Server.MapPath(filename),2
objStream.Close
//============================把文件名写入数据库,如无需要,可删除此段代码!
Set
conn = Server.CreateObject("ADODB.Connection")
conn.open "DRIVER={Microsoft
Access Driver (*.mdb)}; DBQ=" & Server.MapPath("mb.mdb")
set
rs=server.CreateObject("adodb.recordset")
rs.open "select*from
img",conn,1,2
rs.addnew
rs("name")=filename
rs.update
set
rs=nothing
conn.close
set
conn=nothing
//========================================
response.write"<script>alert('图片上传成功!');window.location.href='upload.htm';</script>"
else
response.write"<script>alert('不允许上传"
& houzui &
"的格式!');window.location.href='upload.htm';</script>"
end if
end
if
%>
我复制过去的空格都去掉了,代码是不会有问题了,不过我你看了下,是不是少了上传图片的具体路径啊。还有是不是还需要装一些组件啊 展开
具体的网页文件如下:
asp 文件上传 代码
文件1.上传界面文件 upload.htm
<html>
<head>
<meta
http-equiv="Content-Language" content="zh-cn">
<meta
http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>文件上传</title>
</head>
<body>
<form
method="POST" action="SaveFile.asp">
文件上传:<input type="file"
name="file" size="42"> <input type="submit" value="提交"
name="bb">
</form>
</body>
</html>
文件2.保存上传文件
SaveFile.asp
<%
dim file,filename,houzui
file =
Request.Form("file")
if file=""
then
response.write"<script>alert('请选择要上传的文件!');window.location.href='upload.htm';</script>"
else
houzui=mid(file,InStrRev(file,
"."))
if houzui=".gif" or houzui=".jpg" or houzui=".bmp" then
'允许上传的文件类型
filename=year(date) & month(date) & day(date) &
Hour(time) & minute(time) & second(time) & houzui
Set
objStream = Server.CreateObject("ADODB.Stream")
objStream.Type =
1
objStream.Open
objStream.LoadFromFile file
objStream.SaveToFile
Server.MapPath(filename),2
objStream.Close
//============================把文件名写入数据库,如无需要,可删除此段代码!
Set
conn = Server.CreateObject("ADODB.Connection")
conn.open "DRIVER={Microsoft
Access Driver (*.mdb)}; DBQ=" & Server.MapPath("mb.mdb")
set
rs=server.CreateObject("adodb.recordset")
rs.open "select*from
img",conn,1,2
rs.addnew
rs("name")=filename
rs.update
set
rs=nothing
conn.close
set
conn=nothing
//========================================
response.write"<script>alert('图片上传成功!');window.location.href='upload.htm';</script>"
else
response.write"<script>alert('不允许上传"
& houzui &
"的格式!');window.location.href='upload.htm';</script>"
end if
end
if
%>
我复制过去的空格都去掉了,代码是不会有问题了,不过我你看了下,是不是少了上传图片的具体路径啊。还有是不是还需要装一些组件啊 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询