Jump to content

mkdir Function Error


$Three3

Recommended Posts

Hi everyone, 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.

Link to comment
https://forums.phpfreaks.com/topic/205369-mkdir-function-error/
Share on other sites

"/users/$directory"

 

A leading / on a file system path refers to the root of the current hard disk. I suspect that you want - "users/$directory" or that you want to form an absolute file system path made up of your document root path followed by /users/$directory

"/users/$directory"

 

A leading / on a file system path refers to the root of the current hard disk. I suspect that you want - "users/$directory" or that you want to form an absolute file system path made up of your document root path followed by /users/$directory

 

Thanks a lot man. That worked perfectly.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.