Skip to content

Instantly share code, notes, and snippets.

@stevetrask
Created November 27, 2017 09:54
Show Gist options
  • Save stevetrask/d9b374df4448509f5f2718be46c6c2c0 to your computer and use it in GitHub Desktop.
Save stevetrask/d9b374df4448509f5f2718be46c6c2c0 to your computer and use it in GitHub Desktop.
<?php
function checkRemoteFile($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(curl_exec($ch)!==FALSE)
{
return true;
}
else
{
return false;
}
}
$url = 'https://s3.eu-west-2.amazonaws.com/test.pdf';
$check = checkRemoteFile($url);
if(true == $check){
echo "ok";
}else{
echo "not ok";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment