Revision: 60102
Updated Code
at October 20, 2012 10:24 by o0110o
Updated Code
function file_alive($_path) {
$handle = curl_init($_path);
if (false === $handle) {return false;}
curl_setopt($handle, CURLOPT_HEADER, false);
curl_setopt($handle, CURLOPT_FAILONERROR, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox because some sites request a valid header from you
curl_setopt($handle, CURLOPT_NOBODY, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);
$alive = curl_exec($handle);
curl_close($handle);
return $alive;
}
Revision: 60101
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 20, 2012 10:15 by o0110o
Initial Code
function file_alive($_path) {
$handle = curl_init($_path);
if (false === $handle) {return false;}
curl_setopt($handle, CURLOPT_HEADER, false);
curl_setopt($handle, CURLOPT_FAILONERROR, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox because some sites request a valid header from you
curl_setopt($handle, CURLOPT_NOBODY, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);
$connectable = curl_exec($handle);
curl_close($handle);
return $connectable;
}
Initial URL
Initial Description
This function will use curl to see if a file exists at the location it's provided. It accepts $_path as a parameter.
Initial Title
A function to see if a file exists with curl.
Initial Tags
curl, php, function, files
Initial Language
PHP