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

Link to comment
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

 

Thanks a lot man. That worked perfectly.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.