ASP技巧:判斷遠程圖片是否存在,原理是利用XMLHTTP.status來判斷
function CheckURL(byval A_strUrl)
set XMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
XMLHTTP.open "HEAD",A_strUrl,false
XMLHTTP.send()
CheckURL=(XMLHTTP.status=200)
set XMLHTTP = nothing
end function
Dim imgurl
imgurl="UploadFiles/2007829144940734.gif"
if CheckURL(imgurl) then
response.write "圖片存在"
else
response.write "圖片不存在"
end if
判斷遠程圖片是否存在[JS代碼]
{
var oReq = new ActiveXObject("Microsoft.XMLHTTP")
oReq.open("Get","UploadFiles/2007829144941621.gif",false);
oReq.send();
//alert(oReq.status)
if(oReq.status==404)
alert('不存在');
else
alert("存在")
}