How to see if a remote file exists


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $file = "http://www.dropthenerd.com/demo/file_exists.php";
  2. $fileExists = @file_get_contents($file,null,null,-1,1) ? true : false ;
  3.  
  4. if($fileExists){
  5. echo "File Exists!";
  6. }else{
  7. echo "Sorry, we couldn't find the file.";
  8. }

URL: http://www.dropthenerd.com/how-to-see-if-a-remote-file-exists-php/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.