Question

Is there another way how to make directory in php? mkdir() is not working. I have tried this:

 if (!file_exists('path/to/directory')) {
     mkdir('path/to/directory', 0777, true);
 }

from here: Create a folder if it doesn't already exist

I have no error, no warning, code is doing nothing.

Was it helpful?

Solution

A few things to try:

  • Make sure you have error output enabled (including those pesky E_NOTICEs)
  • As others mentioned, if mkdir returns false, it's a failure. Do you have write access?
  • Are you really passing 'path/to/directory'? If yes, does 'path/to/' already exist? If 'path/to/' doesn't exist, you need to pass the third bool param as true, the docs are pretty clear on what it does.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top