ASP关于远程上传图片大小的问题

来源:百度知道 编辑:UC知道 时间:2024/05/27 16:20:03
代码如下

'==================================================
'过程名:Saveimage
'作 用:保存远程的文件到本地
'参 数:RemoteFileUrl -------- 远程文件URL
' LocalFileName --------- 本地文件名
' imgtype-----1 图片文件,0 所有文件
'返回值:True ------------------- 保存成功
' false ----------------- 保存不成功
'==================================================
function saveimage(RemoteFileUrl,LocalFileName,imgtype)
dim geturl,objstream,imgs,httpimgs
GIFflType = chrb(71) & chrb(73) & chrb(70)
BMPflType = chrb(66) & chrb(77)
JPGflType = Chrb(255) & Chrb(216) & Chrb(255)
saveimage=True
set httpimgs=server.createobject("MSXML2.XMLHTTP.3.0")
With httpimgs
httpimgs.open "Get",RemoteFileUrl,false, "", ""
httpimgs.send()
if httpimgs.readystate<>4 or httpimgs.Status > 300 then
saveimage=False
exit functi

function saveimage(RemoteFileUrl,LocalFileName,imgtype)
dim geturl,objstream,imgs,httpimgs
GIFflType = chrb(71) & chrb(73) & chrb(70)
BMPflType = chrb(66) & chrb(77)
JPGflType = Chrb(255) & Chrb(216) & Chrb(255)
saveimage=True
set httpimgs=server.createobject("MSXML2.XMLHTTP.3.0")
With httpimgs
httpimgs.open "Get",RemoteFileUrl,false, "", ""
httpimgs.send()
if httpimgs.readystate<>4 or httpimgs.Status > 300 then
saveimage=False
exit function
end if
if httpimgs.size < 100 then
saveimage=False
exit function
end if
imgs=httpimgs.responsebody
End With
set httpimgs=nothing
if imgtype=1 then
if midb(imgs, 1, 3) <>JPGflType then
elseif midb(imgs, 1, 3) <> GIFflType then
elseif midb(imgs, 1, 2) <> BMPflType then
saveimage=False
exit function
end if
end if