0

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.

http://i.prntscr.com/b5f37f0ff84f471bb62f250369c41625.png

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);
  print_r(error_get_last());
}

Thanks in advance!

Community
  • 1
  • 1
JC97
  • 1,530
  • 2
  • 23
  • 44

1 Answers1

3

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.

JC97
  • 1,530
  • 2
  • 23
  • 44