Error creating directory using mkdir function in Codeigniter Error creating directory using mkdir function in Codeigniter codeigniter codeigniter

Error creating directory using mkdir function in Codeigniter


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}


Use this to specify it the working directory, it might be confused as to where the directory is located.

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

getcwd is the working directory for your codeigniter. You can search in the PHP guide the getcwd() function to make it clearer.

This should work.

EDIT

To make it clearer, that would return the following:

C:\xampp\htdocs\YOUR_ROOT_DIRECTORY\docs\client\bills\payd

EDIT AGAIN

Although after reading again, this would only create payd and assume that docs\client\bills is already created. You could create client and bills using mkdir or using the file explorer. But there are other PHP ways and I can help if needed.

Goodluck meyt


I also had this weird "1341" permissions error with PHP mkdir, nothing to do with CodeIgniter, it's a pure PHP issue!

After much experimentation, the only way I could get it to work was to include a slash at the end of the path, and set the recursive flag to 'true'. (Even though the PHP docs don't show a final slash, and I was only creating a single directory.)

I.e.

$existing_path = '/these/directories/already/exist/';mkdir( $existing_path . 'new-directory/', 0755, true);