error message Warning: mkdir() [function.mkdir]: No such file or directory


i am trying to create a very simple ftp page on my website which will allow users to upload files and make directories and upload files to those directories as well as delete files and directories.

So i got to about here:

$createdir = $_POST[‘create’];
$nameoffile = $_POST[‘nameoffile’];
if ($createdir) {
mkdir(“uploads/” . $nameoffile, 0777);
echo “Folder created”;}
else echo “Failed to create folder”;

this is for a small form that allows user to put his filename and upload it. I get this error

Warning: mkdir() [function.mkdir]: No such file or directory in /path/path/path

can someone help me out please?

pretty self exclamatory error there. Need to check that the path is correct. If $nameoffile is the actual file that users are uploading, then you need use $_FILE instead. The simplest way of determing what’s being posted is to just echo the variables.

$nameoffile = $_POST[‘nameoffile’];
echo $nameoffile."

If the path information is correct, then move onto the path in the function. Could be as simple as adding a / in front of uploads (/uploads/). You’ll probably have to use chmod to change the folder permissions, i’ve never had it work with mkdir. just create the folder first, then chmod it.

Note that you cannot create multiple directories at the same time. e.g.


If all you have existing is /create/path but need to create /to/here then you need to first create /to then /to/here

Hi thanks for the reply

I am not creating multiple directories. The script is in a folder with a subfolder called “uploads”. I want the directories to get created in that subfolder which is one step down. hence the line of code:

[php]mkdir(“uploads/” . $nameoffile, 0777);[/php]

the variable $nameoffile is what name of the directory will be as specified by user

You should check that the PHP user has permissions to create directories there

thanks! that sounds like its worth a try, but um… this might sound like a dumb question but, do you know where one might do that? in Cpanel?

Not a permission problem, if the script running in subfolder and you want to create the user’s folder outside of that, then you need to back the starting folder up. instead of just uploads, it needs to be …/uploads. either that, or use the absolute path.

you can check permissions through cpanel, just use the file manager (eitiher one). Should be a link when you click on the folder to view or edit the permissions. really shouldn’t be giving users that high of permissions though, the standard 644 is more than sufficient to store files.

Sponsor our Newsletter | Privacy Policy | Terms of Service