if (!file_exists($dirname)) {
if (@mkdir($dirname, 0777)) {
// success
}
else {
// failure
}
}
else {
// file or directory with that name already exists
}
as for "0777" mode, the first digit will almost always be 0 (atleast for what you'll be doing) and the next three digits are for owner, owner's group, and everybody else's privileges (respectively)
7 = read + write + execute
the breakdown:
0 = no privileges
1 = execute privileges
2 = write privileges
4 = read privileges
Just add them up to what you want (1 + 2 + 4 = 7)
so access privileges of 5 = 1 + 4 = execute and read privileges, but no write privileges