怎样用asp实现图片上传到文件夹,路径保存在access数据库中

2024-11-24 08:17:11
推荐回答(1个)
回答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
%>