Skip to content

Instantly share code, notes, and snippets.

@emmgfx
Last active December 11, 2015 02:19
Show Gist options
  • Save emmgfx/4530058 to your computer and use it in GitHub Desktop.
Save emmgfx/4530058 to your computer and use it in GitHub Desktop.
Comprobar si archivo remoto existe con PHP
<?PHP
function remote_file_exists($file){
$ch = curl_init($file);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if($retcode==200 || $retcode==302){
return true;
}else{
return false;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment