Question

I am stuck on a simple script. I have tried Googling it and I have tried all of the stuff I found on Google but none of it has worked for me. I am trying to you the mkdir function but I keep getting an error that says: Warning: mkdir() [function.mkdir]: No such file or directory in /home/content/l/i/n/web/html/php/mkdir.php on line 6

Here is my code:

<?php

//Create the directory for the user
$directory = time() . rand(0, 49716) ;

if (mkdir("/users/$directory", 0777)) {
    echo '<p>Directory was created successfully.</p>' ;
} else {
    echo '<p>Directory was NOT created.</p>' ;
}

?>

I am placing the script called mkdir.php in the same folder as the users folder. The users folder has the permissions set to 0777. I am not sure why I keep getting this error because the users folder does exists. Any help is greatly appreciated.

Was it helpful?

Solution

if (mkdir("users/$directory", 0777)) {

:-)

OTHER TIPS

Nevermind I figured it out. It was just that the first slash in "/users/$directory" should be "users/$directory".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top