PHP/File Directory/File Open

Материал из Web эксперт
Перейти к: навигация, поиск

Checking That a File Exists

   <source lang="html4strict">

<?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"; 

?>

      </source>