Reputation: 795
My php script is located in /var/www/html/users/dev
. I need to create a folder in /var/www/images/
- something like /var/www/images/test/test/
and store here some images.
But when i trying is with mkdir($file_dir, 0777);
where $file_dir
is /var/www/images/test/test/
i receive an error:
Warning: mkdir(): No such file or directory in /var/www/html/users/dev/classes/sites.class.php...
Upvotes: 0
Views: 4349
Reputation: 227
Because "/var/www/images/test"
does not exists, so you can not mkdir("/var/www/images/test/test")
You can specify the "$recursive"
to TRUE
, and it will work, like this:
mkdir($file_dir, 0777, TRUE);
Upvotes: 9
Reputation:
if it is Linux you have set permissions to your parent directory 1st.
sudo chmod -R 777 /path of ur directory.
Upvotes: 1
Reputation: 116110
Try
mkdir($file_dir, 0777, true);
The third parameter ('recursive') allows you to specify a path of which all directories will be created. If you don't, only the last directory ('test') will be created, and the whole path before that must exist.
The PHP documentation is quite clear about that.
Upvotes: 1