I have the following problem.
The upload script I have creates 2 directories on the server
/directoryX
/directoryX/thumbs
X = the directory number, after every 1000 files uploaded, the directory goes 1 dir up (so directory1 becomes directory2).
The problem is that /directoryX is created with the wrong rights, so that I don't have permission to create the thumbs directory.
I use below script.
// $var_username = the name the script gets from loggin in
$userpath = strtolower("uploads/$var_username");
$counter = '1';
if (!is_dir($userpath)) { // Set / create the userdirectory
$oldumask = umask(000);
mkdir("$userpath", 0777);
umask($oldumask);
}
$path = strtolower("uploads/$var_username/directory$totaldirs");
$paththumb = strtolower("uploads/$var_username/directory$totaldirs/thumbs");
if (!is_dir($path)) {
$oldumask = umask(000);
mkdir($path, 0777);
mkdir($paththumb, 0777);
umask($oldumask);
$resultdir = "Directory '<b>$path</b>' created, directory changed";
}
else {
$resultdir = "Current directory is '<b>$path</b>'";
}
$totalfiles = filecount($path);
if ($totalfiles >= '1000') {
$newdircounter = $totaldirs + 1;
$path = strtolower("uploads/$var_username/directory$newdircounter");
$resultdir = "Directory '<b>$path</b>' created, directory changed";
mkdir($path);
}
Anybody a clue why sometimes the directories aren't created with the right permissions ??