SaveRemoteFile函数之asp实现保存远程的文件到本地的代码
程序员文章站
2022-07-01 23:47:19
'================================================== '过程名:saveremotefile '作 ...
'==================================================
'过程名:saveremotefile
'作 用:保存远程的文件到本地
'参 数:localfilename ------ 本地文件名
'参 数:remotefileurl ------ 远程文件url
'==================================================
function saveremotefile(localfilename,remotefileurl)
saveremotefile=true
dim ads,retrieval,getremotedata
on error resume next
set retrieval = server.createobject("microsoft.xmlhttp")
with retrieval
.open "get", remotefileurl, false, "", ""
.send
if .readystate<>4 or .status > 300 then
saveremotefile=false
exit function
end if
getremotedata = .responsebody
end with
set retrieval = nothing
'if lenb(getremotedata) < 100 then exit function
'if maxfilesize > 0 then
'if lenb(getremotedata) > 5000 then exit function
response.write(round(lenb(getremotedata)/1024)) & "kb"
'end if
set ads = server.createobject("adodb.stream")
with ads
.type = 1
.open
.write getremotedata
.savetofile server.mappath(localfilename),2
.cancel()
.close()
end with
if err.number<>0 then
saveremotefile=false
exit function
err.clear
end if
set ads=nothing
end function
'过程名:saveremotefile
'作 用:保存远程的文件到本地
'参 数:localfilename ------ 本地文件名
'参 数:remotefileurl ------ 远程文件url
'==================================================
function saveremotefile(localfilename,remotefileurl)
saveremotefile=true
dim ads,retrieval,getremotedata
on error resume next
set retrieval = server.createobject("microsoft.xmlhttp")
with retrieval
.open "get", remotefileurl, false, "", ""
.send
if .readystate<>4 or .status > 300 then
saveremotefile=false
exit function
end if
getremotedata = .responsebody
end with
set retrieval = nothing
'if lenb(getremotedata) < 100 then exit function
'if maxfilesize > 0 then
'if lenb(getremotedata) > 5000 then exit function
response.write(round(lenb(getremotedata)/1024)) & "kb"
'end if
set ads = server.createobject("adodb.stream")
with ads
.type = 1
.open
.write getremotedata
.savetofile server.mappath(localfilename),2
.cancel()
.close()
end with
if err.number<>0 then
saveremotefile=false
exit function
err.clear
end if
set ads=nothing
end function
上一篇: 简单的纯js三级联动
推荐阅读
-
PHP实现的一个保存远程文件到本地的函数分享
-
SaveRemoteFile函数之asp实现保存远程的文件到本地的代码
-
CheckFile函数之asp实现检查某一文件是否存在的代码
-
ReSaveRemoteFile函数之asp实现查找文件保存替换的代码
-
ASP保存远程图片到本地 同时取得第一张图片并创建缩略图的代码
-
PHP实现的一个保存远程文件到本地的函数分享
-
ReSaveRemoteFile函数之asp实现查找文件保存替换的代码
-
ASP保存远程图片到本地 同时取得第一张图片并创建缩略图的代码
-
SaveRemoteFile函数之asp实现保存远程的文件到本地的代码
-
CheckFile函数之asp实现检查某一文件是否存在的代码