最近想在自己的BBS里面加个写留言可上传图片. 参考了网上一些前辈的写法.可是,均无法实现.详细细节如下:(可大致看以下,我只精简了一点点代码,未全部精简) 我写提交FORM是这样写的: 其中的关键代码:enctype="multipart/form-data",我只要加了这个东东,那么程序就报错为:带*号的未填,其实带*号的项目我都填了的,去掉这句就不报错(但是去掉这句怎么传图片,?!@#$???). <form method="post" name="input" enctype="multipart/form-data" action="write.asp?action=new"> <tr> <td align="right"><span style="color: #9999CC">昵称:</span></td> <td align="right"> </td> <td colspan="2"><input name="name" type="text" id="name" value="<%=rsvip("xingming")%>" size="30" maxlength="12" ><span style="color: #FF0000"> *</span></td> </tr> <tr> <td align="right"><span style="color: #9999CC">Q Q:</span></td> <td align="right"> </td> <td colspan="2"><span style="color: #666666"><input name="qq" type="text" id="qq" value="<%=rsvip("oicq")%>" size="30" maxlength="10"><span style="color: #FF0000"> *</span></span></td> <td width="273" rowspan="4"><img id="strface" src="images/humen/1.gif"></td> </tr> <tr> <td align="right"><span style="color: #9999CC">主页:</span></td> <td align="right"> </td> <td colspan="2"><input name="homeurl" type="text" id="homeurl" value="<%=rsvip("home")%>" size="30"></td> </tr> <tr> <td align="right"><span style="color: #9999CC">邮箱:</span></td> <td align="right"> </td> <td colspan="2"><span style="color: #666666"><input name="mail" type="text" id="mail" value="<%=rsvip("email")%>" size="30"><span style="color: #FF0000"> *</span></span></td> </tr> <tr> <td align="right"><span style="color: #9999CC">头像:</span></td> <td align="right"> </td> <td width="153"><select name="face" onChange="document.images['strface'].src=options[selectedIndex].value;"> <% for i=1 to 108 response.write ("<option value='images/humen/" & i & ".gif'>头像" & i & "</option>") next %> </select></td> <td colspan="2"> </td> </tr> <tr> <td align="right"><span style="color: #9999CC">标题:</span></td> <td align="right"> </td> <td colspan="2"><span style="color: #666666"><input name="title" type="text" id="title" value="" size="30" maxlength="50" ><span style="color: #FF0000"> *</span></span></td> </tr> <tr> <td align="right">留言:</td> <td align="right"> </td> <td colspan="3"><textarea name="content" style="width:400px" rows="9" wrap="VIRTUAL" id="Message" onSelect="javascript: storeCaret(this);" onClick="javascript: storeCaret(this);"></textarea></td> </tr> <tr> <td align="right"> </td> <td align="right"> </td> <td colspan="3" width="400" align="center"><span style="color: #FF0000">为了避免服务器负担过重,本次留言字数限制在2万字.</span></td> </tr> <tr> <td align="right"> </td> <td align="right"> </td> <td>上传图片:<input type=file name=mefile style="font-size:9pt"></td> </tr> <tr> <td align="right"> </td> <td align="right"> </td> <td height="30" colspan="5" width="400" align="center"><input name="提交" type="submit" id="提交" value="提交发言"></td> </tr> </form> 本页中的action=new是这样写的: <% on error resume next dim iname, iqq, ihomeurl, imail, icontent,itime,imsg,ierror
if request("action") = "new" then
response.buffer=true formsize=request.totalbytes '获取提交数据量的总字节数 formdata=request.binaryread(formsize) '保存从客户端读取到的数据 '优化读取到的二进制数据 bncrlf=chrB(13) & chrB(10) divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1) datastart=instrb(formdata,bncrlf & bncrlf)+4 dataend=instrb(datastart+1,formdata,divider)-datastart mydata=midb(formdata,datastart,dataend)
iname = inohtml(trim(request("name"))) iszid = inohtml(trim(request("szid"))) iqq = inohtml(trim(request("qq"))) ihomeurl = inohtml(trim(request("homeurl"))) imail = inohtml(trim(request("mail"))) ititle = inohtml(trim(request("title"))) icontent = inohtml(trim(request("content"))) iface = request("face") iip = request.servervariables("Remote_Addr") itime = now() if iname="" or imail="" or iqq="" or icontent="" or ititle="" then ierror = "带*号项不能为空!" elseif isvalidemail(imail) = false then ierror = "邮箱格式不正确!" elseif IsNumeric(iqq) = false then ierror = "你的QQ号要是数字哦!" elseif len(iqq) < 5 or len(iqq) >12 then ierror = "你不可能有这样的QQ吧?" elseif len(ititle) > 100 then ierror = "留言标题不能超过100个字!" elseif len(icontent) < 8 then ierror = "你的留言字数不能小于8个。拿点灌水的勇气出来嘛!" elseif len(icontent) > imax then ierror = "你的话太多了呀,枪毙!" else strconn = "select * from ebook" set rs = server.createobject("adodb.recordset") rs.open strconn, conn, 1, 3 rs.addnew rs("fname") = iname rs("fszid") = iszid rs("fqq") = iqq rs("fhomeurl") = ihomeurl rs("fmail") = imail rs("ftitle") = ititle rs("fcontent") = icontent rs("ftime") = itime rs("fip") = iip rs("fface") = iface rs("fimg").AppendChunk myData rs.update rs.close set rs = nothing if err.number = 0 then response.redirect ("index.asp") else session("imsg") = "2" response.redirect ("msg.asp") end if end if end if %> 请前辈指点迷径