PHP: mkdir() permission denied

I know there are a lot of topics about this 'problem', and I tried every solution proposed here: PHP mkdir: Permission denied problem But I still get the permission denied when I'm trying to make a folder using a PHP script.

For testing i've put everything under 777. albums is the one where I have to make sub dirs. In this case it's 755, but it also doesn't work with 777.

Really don't know what I can do next since I've been looking on google en SO for a few hours but still haven't got anything working.

My code to create the dir is as follows:

$target_path = DEFAULT_UPLOAD_PATH . $albumId . '/';
//    albums/{xxxx-xxxx-xxxx}/

if (!is_dir($target_path)) {
  mkdir($target_path, 0755, true);


  • The problem had nothing to do with permissions, but with the location of the target path. It was a relative path, but I converted it to an absolute path with the $_SERVER['DOCUMENT_ROOT'] variable.