php tutorial to determine whether the remote picture exists
function img_exits ($ url)
{
$ ch = curl_init ();
curl_setopt ($ ch, curlopt_url, $ url);
curl_setopt ($ ch, curlopt_nobody, 1); // Do not download
curl_setopt ($ ch, curlopt_failonerror, 1);
curl_setopt ($ ch, curlopt_returntransfer, 1);
if (curl_exec ($ ch)! == false)
return true;
else
return false;
}
//Method Two
function img_exists ($ url)
{
if (file_get_contents ($ url, 0, null, 0,1))
return 1;
else
return 0;
}
//
/ **
@title: How to check for the existence of a remote file (php5)
@author: axgle
@version: 1.0
* /
$ url = 'http: //www.jzread.com/';
echo url_exists ($ url);
function url_exists ($ url) {
$ head = @ get_headers ($ url);
if (is_array ($ head)) {
return true;
}
return false;
}
?>
Web effects methods
<script language = "webpage effects">
function geturl (url)
{
var xmlhttp = new activexobject ("microsoft.xmlhttp");
xmlhttp.open ("get", url, false);
xmlhttp.send ();
if (xmlhttp.readystate == 4)
alert ((xmlhttp.status == 200)? "file exists": "file does not exist");
}
</ script>
Please enter the file address: <input name = "file" id = "file" value = "http://www.jzread.com">
<button onclick = "geturl (file.value)"> test address </ button>