怎样用asp实现图片上传到文件夹,路径保存在access数据库中
请各位高手指点一下:我正在做一个asp站,情况如下根目录(mysite),数据库在(mysite-admin-data-database.mdb),在database.m...
请各位高手指点一下:我正在做一个asp站,情况如下根目录(mysite),数据库在(mysite-admin-data-database.mdb),在database.mdb中有一个叫member的表,它包含m_name,m_pwd,m_email,m_photo等字段名,在一个注册用户的页面中用户通过在输入框中输入用户名,密码,邮箱号码,并用文件域来让用户上传照片.我想实现把上述用户的信息保存在database.mdb数据库中(其中上传的照片上保存到根目录下的upload的文件夹中,照片的路径保存到数据库中),请问这该如何实现呢?请各位高手不吝赐教!小弟在此感激不尽!
展开
1个回答
展开全部
问题:往数据库添加大量图片,不能再用一张张往数据库里加的方法了(那多累多烦琐啊),能有什么方法做到自动遍历读取某目录下的图片文件,一次能添加多一点的图片(几十、几百都好啊)??
代码:
<%
set rs=server.createobject("adodb.recordset")
conn = "Provider=SQLOLEDB;Data Source=10.0.0.3;Initial Catalog=yourdb;User ID=sa;password=sa"
sql="select picname from yourtable"
rs.open sql,conn,3,2
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set uploadFolder=objFSO.GetFolder(Server.MapPath("uploadimages\"))
Set uploadFiles=uploadFolder.Files
For Each Upname In uploadFiles
upfilename="upload/"&upname.name
rs.addnew
rs("picname")=upfilename
next
rs.close
set rs=nothing
set uploadFolder=nothing
set uploadFiles=nothing
%>
代码:
<%
set rs=server.createobject("adodb.recordset")
conn = "Provider=SQLOLEDB;Data Source=10.0.0.3;Initial Catalog=yourdb;User ID=sa;password=sa"
sql="select picname from yourtable"
rs.open sql,conn,3,2
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set uploadFolder=objFSO.GetFolder(Server.MapPath("uploadimages\"))
Set uploadFiles=uploadFolder.Files
For Each Upname In uploadFiles
upfilename="upload/"&upname.name
rs.addnew
rs("picname")=upfilename
next
rs.close
set rs=nothing
set uploadFolder=nothing
set uploadFiles=nothing
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询