mkdir() says theres no such directory and fails?

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).


You have an error in your string:

mkdir("images/listing-images/rent/'.$insertID.");

should be:

mkdir("images/listing-images/rent/$insertID");

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.


$path = 'd:\path\to\my\file';
mkdir($path, null, true);

This is copied from the php manual. The last argument "true" allows the creation of subfolders

Tags:

Php

Upload

Mkdir