Forum Moderators: coopster
It would like to know how I do to create a folder inside the other of dynamic form. For former:
Year / month / day
I tried to create doing this way:
<?php
$year = date("Y");
$month = date("m");
$day = date("d");
If(!file_exists($year)){
$createsyear = mkdir("$year", 0777);
If(!file_exists($ month)){
$createsmonth = mkdir("$year/$month", 0777);
If(!file_exists($ day)){
$createsday = mkdir("$year/$mês/$dia", 0777);
}
}
}
?>
The problem is that did not work correctly. He only creates if does not have no folder in the server. In case it have a folder he no longer creates the others.
Will it it be what anybody could help to solve that problem?
Thanks
If(!file_exists($year)){
$createsyear = mkdir("$year", 0777);
} else {
If(!file_exists($ month)){
$createsmonth = mkdir("$year/$month", 0777);
} else {
If(!file_exists($ day)){
$createsday = mkdir("$year/$mês/$dia", 0777);
} else {
}
}
?>
The other thing is that mkdir needs something to work. Either exec or system.
for example:
exec("mkdir path\to\file")
Try that let me know. Take a look at your error logs also, that can help lead you in the right direction.
this works fine
<<<
<?php
$year = date("Y");
$month = date("m");
$day = date("d");
If(!file_exists($year)){
$createsyear = mkdir("$year", 0777);
}
else
{
If(!file_exists("$year/$month")){
$createsmonth = mkdir("$year/$month", 0777);
}
else
{
If(!file_exists($year/$month/$day)){
$createsday = mkdir("$year/$month/$day", 0777);
}
else
{
// whatever
}
}
}
?>