Im likely doing something very simply wrong, but when I try to make a directory (using a variable of an insert just performed as the last folder name), I get the error:
Warning: mkdir() [function.mkdir]: No such file or directory in /home/blah/blah
with the code:
if (!is_dir("images/listing-images/rent/'.$insertID.")) { //make new directory with unique id mkdir("images/listing-images/rent/'.$insertID."); }
of course the directory doesn't exist.. I'm trying to make it now? confused!
If you get a permission denied error, you have not permissions to create a directory in the specified path. Check if you can get around the problem by modifying the group membership or ownership, so that you get the permission needed for the whole directory path involved.
The mkdir() function shall fail if: [EACCES] Search permission is denied on a component of the path prefix, or write permission is denied on the parent directory of the directory to be created.
It happens because you don't have images/listing-images/rent
path existing in your filesystem.
If you want to create the whole path - just pass the 3rd argument as a true
:
mkdir('images/listing-images/rent/'.$insertID, 0777, true);
There is also a chance you're in a wrong directory currently. If this is the case - you need to change the current dir with chdir()
or specify the full path.
Assuming you're using PHP > 5.0.0, try mkdir("path", 0777, true);
to enable creating directories recursively (see here: http://php.net/manual/en/function.mkdir.php).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With