Checking That a File Exists : File Open « File Directory « PHP






Checking That a File Exists


<?php
  $myfile = "./test.txt";
  if (file_exists ($myfile)){
    $msg="File already exists. ";
  }else{
    $myfile = @fopen ($myfile, "w+") or die ("Couldn't create the file"  );
    $msg= "File created! " ;
    fclose ($myfile);
  }
  echo "$msg"; 
?>
           
       








Related examples in the same category