0

I am trying to create a directory with mkdir code. When I use this code :

mkdir("test");

then, the "test" directory will be created. But when I try something like this

mkdir($_SESSION['username']);

then, I got an error saying

Warning: mkdir(): open_basedir restriction in effect. File() is not within the allowed path(s)

What does this mean? I also tried

$path = $_SESSION['username'];
mkdir($path);

and

mkdir("".$_SESSION['username']."");

but it gives me the same error message. What am I supposed to do?

Steven Tomko
  • 98
  • 11

1 Answers1

2

Make sure you prefix the folder name with the full path to where you want to create the folders. Ie, if you are trying to create folders under /tmp/users then you might use code like:

mkdir('/tmp/users/' . $_SESSION['username']);

You also need to make sure that you have configured PHP to allow you to access that path. See the open_basedir ini directive: http://php.net/manual/en/ini.core.php#ini.open-basedir

Jeremy Giberson
  • 1,053
  • 8
  • 15
  • File permissions might be an issue as well, you have to make sure the directory is writable by the web server. – Joseph Crawford Apr 09 '15 at 18:36
  • @JosephCrawford OP: *"And I did error reporting but nothing came on"* - Had it been a permissions issue, it would have told them so; least one would think it would. Who knows. – Funk Forty Niner Apr 09 '15 at 18:39