Piet
Piet

Reputation: 2208

mkdir fails in every way

Got this error: mkdir(): No such file or directory.

This is strange because ofcourse the directory doesn't exists because i want to create it. I checked the rights and its 0777.

The folder I tried to create is in: http://www.mysite/uploads/images/

so after folder creation it should look like: http://www.mysite/uploads/images/1

Anyone who can help me?

if (file_exists($upload_dir) == false)
{
    mkdir($upload_dir, 0777);
}

Upvotes: 0

Views: 2736

Answers (2)

Saty
Saty

Reputation: 22532

Instead of given url path http://www.mysite/uploads/images/1 you need to given relative path of folder like

$upload_dir="/var/www/html/your_folder";// path of your folder

    mkdir($upload_dir, 0777);

mkdir only works on The directory path

Upvotes: 1

Alexey  Eremikhin
Alexey Eremikhin

Reputation: 51

mkdir function returns 'No such file or directory' in case there are not all parent directories exists. Please refer to third mkdir argument if you need recursive creation

mkdir($upload_dir, 0777, true);

Upvotes: 4

Related Questions