To determine whether a remote picture exists

Source: Internet
Author: User

To determine whether a remote picture exists [ASP code]

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 "Picture exists"
Else
Response.Write "Picture does not exist"
End If

To determine whether a remote picture exists [JS code]

{
var oreq = new ActiveXObject ("Microsoft.XMLHTTP")
Oreq.open ("Get", "Uploadfiles/2007829144941621.gif", false);
Oreq.send ();
Alert (Oreq.status)
if (oreq.status==404)
Alert (' does not exist ');
Else
Alert ("exist")
}

Here we use the XMLHTTP to read the image on the remote server and return the status.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.