PHP uses curl to determine whether the remote file exists. Please see the code below:
// Determine the remote file
Function check_remote_file_exists($url)
{
$curl = curl_init($url);
// Do not retrieve data
curl_setopt($curl, CURLOPT_NOBODY, true);
// Send request
$result = curl_exec($curl);
$found = false;
// If the request is not sent, it fails
if ($result !== false) {
// Check again whether the http response code is 200
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($statusCode == 200) {
$found = true;
}
}
curl_close($curl);
return $found;
}