紧急求救
asp吧
全部回复
仅看楼主
level 1
苦生若甜 楼主
我自学ASP制作动态网页,书上及所带的光盘给出实例,现遇到一个上传图片测试无法实现的问题,研究了3个月,也没浏览出来,请高手帮个忙告诉程序中哪错了,怎么改?一\下面是测试中的错误提示:错误类型:ADODB.Stream (0x800A0BBC)写入文件失败。/8/up.asp, 第 99 行(我查对了一下第99行也就是下面up.asp文件的倒数第十五行,即upstreamend.savetofile(server.mappath(picsavefolder&filename)))二\up.asp文件的代码如下:<% dim siteurl,picsavefolder,limitbyte,lsfilename picsavefolder = "uppic/" '图片保存文件夹(以"/"符号结尾) limitbyte = 300 '文件大小限制,单位:kif request.totalbytes < 192 then%>
文件上传

这是一个实现文件上传的例子:
请选择文件:

     大小限制:<%=limitbyte%>k <%else dim contentlen '接收表单信息 contentlen=request.totalbytes '检测文件大小 if contentlen>limitbyte*1024 then response.write "文件超过"&limitbyte&"k,不允许上传!" else dim content '读取上传文件信息 content=request.binaryread(request.totalbytes) '二进制相互转换函数 Function getByteString(StringStr) For i=1 to Len(StringStr) char=Mid(StringStr,i,1) getByteString=getByteString&chrB(AscB(char)) Next End Function Function getString(StringBin) getString ="" For intCount = 1 to LenB(StringBin) getString = getString & chr(AscB(MidB(StringBin,intCount,1))) Next End Function '处理数据 dim upbeg,upend,lineone,linetwo,linethree,line1,line2,line3 upbeg=1 upend=instrb(upbeg,content,getbytestring(chr(10))) lineone=midb(content,upbeg,upend-upbeg) upbeg=upend+1 line1=lenb(lineone) upend=instrb(upbeg,content,getbytestring(chr(10))) linetwo=midb(content,upbeg,upend-upbeg) upbeg=upend+1 line2=lenb(linetwo) upend=instrb(upbeg,content,getbytestring(chr(13))) linethree=midb(content,upbeg,upend-upbeg) line3=lenb(linethree) '获得文件名 dim pp,checknametemp,checklen,checkname,filename pp=instrb(1,linetwo,getbytestring(chr(46))) checknametemp=rightb(linetwo,line2-pp+1) checklen=instrb(1,checknametemp,getbytestring(chr(34))) checkname=getstring(leftb(checknametemp,checklen-1)) '检测文件后缀 if checkname<>"Content-Disposition: form-data; name=" then if checkname=".txt" or checkname=".doc" or checkname=".gif" or checkname=".jpg" or checkname=".jpeg" or checkname=".zip" or checkname=".rar" or checkname=".bmp" or checkname=".png" or checkname=".swf" then '定义文件名 filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&checkname '上传文件 dim alllen,upstream,upstreamend,file alllen=line1+line2+line3+6 set upstream=server.createobject("adodb.stream") set upstreamend=server.createobject("adodb.stream") upstream.type=1 upstreamend.type=1 upstream.open upstreamend.open upstream.write content upstream.position=alllen file=upstream.read(clng(contentlen-alllen-line1-5)) upstreamend.write file upstreamend.savetofile(server.mappath(picsavefolder&filename)) upstream.close upstreamend.close set upstream=nothing set upstreamend=nothing response.write "文件上传成功!
复制下面红色的文件名到图片提交栏,
文件名
"&picsavefolder&filename&"" else response.write "不允许上传"&checkname&"格式文件" end if else response.write "您没有填写文件名" end if end ifend if%>三\文字和图片添加页newsadd.asp代码是
添加公告
<!--.text {FONT-WEIGHT: normal; FONT-SIZE: 12px; WORD-SPACING: 2px; COLOR: #000000; LINE-HEIGHT: 17px; FONT-FAMILY: "宋体"; TEXT-ALIGN: justify; TEXT-DECORATION: none}-->

添加公告

公告标题:



公告作者:



公告图片:

上传

公告内容:





2006年06月19日 08点06分 1
level 1
uppic这个文件夹是否存在,并在正确的文件夹下,即up.asp文件的同一文件夹中,另一个可能是IIS的权限设置问题,uppic文件夹没有写入权限
2006年06月20日 03点06分 2
level 1
我用你的代码,使用成功了
2006年06月20日 03点06分 3
level 1
苦生若甜 楼主
老师啊,您好!非常感谢。可是还不行,uppic这个文件夹是存在,而且与up.asp文件在同一文件夹中,但不行。IIS的权限设置问题,uppic文件夹的写入权限怎么设置?
2006年06月21日 14点06分 4
level 0
我现在正在学习asp.net,你得东西可能我不大懂,但我觉得关于你得权限设置 再建立虚拟目录的时候就应该可以设置允许写入。
2006年06月21日 16点06分 5
level 1
Function upload
dim upbeg,upend,lineone,linetwo,linethree,line1,line2,line3,PostfixArray,Array_N,i,flag
upbeg=1
upend=instrb(upbeg,content,getbytestring(chr(10)))
lineone=midb(content,upbeg,upend-upbeg)----(48行)
upbeg=upend+1
问题:
Microsoft VBScript 运行时错误 '800a0005'
无效的过程调用或参数: 'MidB'
\manage\Program\upload.asp, line 48
Host by NetBox Version 2.8 Build 4128
求救啊!!谢谢 谢谢
2016年06月06日 09点06分 8
level 1
'取得完整url,这里没有用到
Function getUrl
Dim temp,ServerUrl
Temp=Split(Request.servervariables("SERVER_PROTOCOL"),"/")
ServerUrl=Lcase(Temp(0))& "://" & Request.ServerVariables("Server_name") &"/"& Path
getUrl = ServerUrl
End Function
还是路径的问题呢?
2016年06月06日 09点06分 10
1