Search code examples
phpmkdir

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);
}

Solution

  • 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