Mega Code Archive

 
Categories / Php / File Directory
 

Using the chmod() Function

<?php      $fr = @fopen("data.txt", 'w');      if(!$fr) {           chmod("data.txt", 0722);           $fr = @fopen("data.txt", 'w');           if(!$fr) {           echo "Error: Couldn't open data.txt (chmod attempted)";                exit;           }      }      fputs($fr, "Write Successful!");      fclose($fr); ?>