有表单和图片一起上传到数据库的程序代码吗?谢谢!

771122 2003-08-19 10:08:48
有表单和图片一起上传到数据库的程序代码吗?谢谢!我着急!
...全文
84 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lfengchao 2003-08-20
  • 打赏
  • 举报
回复
上面的Set obj = Server.CreateObject(".UploadFile")这句话应该是

Set obj = Server.CreateObject("LyfUpload.UploadFile")
lfengchao 2003-08-20
  • 打赏
  • 举报
回复
用LyfUpload上传组件上传文件
up.htm
<html>
<head>
<title>上传图片</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<b><font color="#FF0000">欢迎你在此上传图片:</font></b>
<form name="form1" method="post" action="up.asp" enctype="multipart/form-data">
请输入说明文字:
<input type="text" name="text">
<br>
<br>
请选择图片:  
<input type="file" name="file1">
<input type="submit" name="Submit" value="上传">
</form>
</body>
</html>

up.asp
<!--#include file="lianku.asp"--> '连库文件
<%
filename1="file1"
path1="c:\upimage" '存放上传的文件
Set obj = Server.CreateObject(".UploadFile")
ss=obj.SaveFile(filename1, path1, false) '保存文件到服务器
aa=obj.filetype("file1") '得到文件的Content-Type
text=obj.request("text")
if ss<>"" then
set rs=server.CreateObject("adodb.recordset")
rs.Open "SELECT * FROM shch2",con,2,2
rs.addnew
rs("image")=trim(ss)
rs("text")=trim(text)
rs("wjlx")=trim(aa)
rs.Update
response.write "成功上传"
end if
if ss="3" then
Response.Write "此文件在服务器上已经存在或同名!不能覆盖!请改名或更换文件!<br>"
Response.write "<a href='#' onclick=history.back();>返回</a>"
Response.end
end if
%>

pp4u 2003-08-20
  • 打赏
  • 举报
回复
用SA组件:
set conn=server.CreateObject("adodb.connection")
conn.connectionstring=Application("info_ConnectionString")
conn.open
Set FileMgr = Server.CreateObject("SoftArtisans.FileUp")
'a=filemgr.form("title")
sql="Select * from datamanager"
Set RS = CreateObject("ADODB.Recordset")
RS.open sql,Conn,adOpenKeyset,adLockOptimistic
rs.Addnew
rs("name")=Session("name")
rs("title")=filemgr.form("title")
'rs("type")=filemgr.form("type")

dim sva
sva=filemgr.form("pid")
rs("parentid")=filemgr.form("pid")
rs("content")=filemgr.form("remark")
rs("datetime")=date()
'rs("filename")=filemgr.Form("DocumentPath")
'rs("title")=filemgr.form("title")
If filemgr.Form("file1").TotalBytes <>0 Then
Pos = InstrRev(filemgr.Form("file1").UserFilename , "\")
Pos=Pos+1
RS("filename")= Mid(filemgr.Form("file1").UserFilename ,Pos)
filemgr.Form("file1").SaveAsBlob RS("filevalue")
End If
rs.Update
rs.close
set rs=nothing
chinesun 2003-08-20
  • 打赏
  • 举报
回复
http://www.aspsky.net/download/asp/doufuupload.zip
下载这个后,用zip解压软件打开,看他的源代码。
这个就是有表单和图片一起上传到数据库的程序代码

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧