这是个上传程序,主要想把文件上传至数据库,可选,是文本的话,就只上传文本,是文件的话,就要上传文件了,俺不会上传文件,大哥帮俺改改好吗,谢谢了,
index.htm
<html>
<head> <meta http-equiv="Content-Language" content="en-us"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>文章标题</title> </head>
<body>
<form method="POST" action="upp.asp" name="Form" > <div align="center"> <table width=580 border="2" cellpadding="2" cellspacing="0" bgcolor="#EEEEEE"> <tr> <td width="85">文章标题</td> <td><input type="text" name="biaoti" size="62"></td> </tr> <tr> <td width="85">文章内容</td> <td><textarea rows="9" type="text" name="wenben" cols="60"></textarea></td> </tr> <tr> <td width="85">上传文件</td> <td><input type="file" name="wenjian" size="51"></td> </tr> </table> <p> <input type="submit" value="提交" name="B1" style="border-style: solid; border-width: 1px"> <input type="reset" value="返回" name="B2" style="border-style: solid; border-width: 1px"></p> <p> </div>
</form>
</body>
</html>
upp.asp
<% dim formsize,formdata,CRLF,divider,datastart,datalength,imgdata Response.Buffer=ture formsize=Request.TotalBytes formdata=Request.BinaryRead(formsize) CRLF=chrB(13) & chrB(10) divider=LeftB(formdata,cLng(InstrB(formdata,CRLF))-1) datastart=InstrB(formdata,CRLF & CRLF)+4 dataLength=InstrB(datastart+1,formdata,divider)-datastart imgdata=midb(formdata,datastart,dataLength) If request.form("biaoti") <> "" then Dim conn,sql,rs,connstr set conn=server.createobject("adodb.connection") conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db1.mdb") set rs=server.createobject("adodb.recordset") sql="SELECT * From yuanchuang where (id is null)" rs.open sql,conn,1,3 rs.addnew rs("biaoti")=request.form("biaoti") If request.form("wenben") <> "" Then rs("wenben")=request.form("wenben") Else rs.fields("wenjian").AppendChunk imgdata End If rs.update rs.close set rs=nothing conn.close set conn=nothing Else Response.write"标题不能为空" response.end End If Response.write"上传成功" %>