i wanted to create a file in a directory to be more ogranized and didnt want to have thousands of files in the same spot. i can make files in the same spot as the script but not in other directories.
<?php
error_reporting(E_ALL);
MakeDirectory("tst", $mode = 0777);
function MakeDirectory($dir, $mode = 0777)
{
if (is_dir($dir) || @mkdir($dir,$mode)) return TRUE;
if (!MakeDirectory(dirname($dir),$mode)) return FALSE;
return @mkdir($dir,$mode);
}
chmod($dir, 0777);
chmod($ourFileName , 0777);
$ourFileName = "test.txt";
$ourFileHandle = fopen($ourFileName, 'w')or die("error opening or creating file");
fclose($ourFileHandle);
?>
Anther question, can MakeDirectory(); function be used to create a directory and in that anther directory? because that didnt work for me either.