求一ASP实现图片上传到数据库的代码

来源:百度知道 编辑:UC知道 时间:2024/05/11 18:35:37
只要能够实现,浏览文件夹,将图片的路径写入到ACCESS数据库,方便调用...............................

<!--#include file="adovbs.inc"--> '上传组件页,系统自带
<%
'功能:取得服务端相对图片路径
'参数:客户端图片路径
'返回值:图片路径
Function GetFileName(imagespath)
If imagespath<>"" Then
GetFileName="UpImages/"&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&Right(imagespath,4) 'UpImages可以改为所需存放图片资料夹名称
Else
GetFileName=""
End If
End Function
'功能:用stream组件上传图片
'参数:客户端图片路径
'返回值:成功返回1,失败返回0
Function UpImages(imagespath)
Set objStream=Server.CreateObject("ADODB.Stream")
objStream.Type=1 'adTypeBinary
objStream.Open
objStream.LoadFromFile imagespath
objStream.SaveToFile Server.MapPath(GetFileName(imagespath)),adSaveCreateOverWrite
objStream.Close
If ERR.number<>0 Then
UpImages=0
Else
UpImages=1
End If
End Function
'============