asp如何远程上传文件

如何上传数据库文件到服务器
2025-02-22 22:01:55
推荐回答(2个)
回答1:

示例如下

<%
function saveimg(url)
dim temp,ranNum,filename,xmlhttp,imgcon,objAdostream,savepath,rdate,rfolder
savepath=server.mappath("/pic")
'response.write server.mappath("/pic")
'savepath=replace(savepath,"\","/")
'savepath=savepath&"/"
'savepath=replace(savepath,"//","/")

temp=split(url,".")
'以下是用时间与随机数重命名文件名
rdate=now
randomize
ranNum=int(90000*rnd)+10000
filename=year(rdate)&month(rdate)&day(rdate)&hour(rdate)&minute(rdate)&second(rdate)&ranNum&"."&temp(ubound(temp))
'文件名重命名结束

'rfolder=year(rdate)&"_"&month(rdate)
'if len(month(now))<2 then
'rfolder=year(now)&"0"&month(now)
'else
'rfolder=year(now)&month(now)
'end if
'savepath=savepath&rfolder
'call FSOfolder(Server.MapPath(savepath))

set xmlhttp=server.createobject("Mi"&"cros"&"oft.XM"&"LHTTP")
xmlhttp.open "get",url,false
xmlhttp.send
imgcon=xmlhttp.ResponseBody
set xmlhttp=nothing
set objAdostream=server.createobject("AD"&"ODB"&".Str"&"eam")
objAdostream.Open()
objAdostream.type=1
objAdostream.Write(imgcon)
'response.write savepath
objAdostream.SaveToFile(savepath&"/"&filename)
objAdostream.SetEOS
set objAdostream=nothing
saveimg=savepath&"/"&filename
response.write saveimg
end function
call saveimg("http://www.sinaimg.cn/home/07index/sinahome_ws_009.gif")
%>

回答2:

用化境无组件上传代码。