Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating directory using mkdir function in Codeigniter

I'm trying to recursively create a directory using php's mkdir function in a Codeigniter installation. My code looks like this:

mkdir('docs/client/bills/payd', 0777, true)

The docs directory already exists in my site root dir, the client directory is beeing created with 0755 permission, the bills directory is beeing created with permission 1341 (weird!) and the last directory, payd, is never created.
I tryed to change permission in the mkdir argument list to 0, 755, etc... and nothing has changed. I also tryed to set umask to 0, 0777... and nothing.

umask(0777);
mkdir('docs/client/bills/payd', 0777, true)

Can anyone please say what am I doing wrong? The code above is called from a Codeigniter regular controller.

like image 528
Nowdeen Avatar asked Dec 08 '25 06:12

Nowdeen


1 Answers

Try with

if ( ! is_dir( FCPATH.'docs/client/bills/payd' )//FCPATH is absolute path to the project directory
{
    mkdir( FCPATH.'docs/client/bills/payd', 0777, true );//although 0755 is just fine and recomended for uploading and reading
}
like image 168
Tpojka Avatar answered Dec 09 '25 19:12

Tpojka