Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MkDir failed (No such file or directory)

Status
Not open for further replies.

sanjdhiman

Programmer
Jan 15, 2003
189
0
0
GB
Hi there i get the following error when tryin to do the following on a WinXP Home editio nwith Apache and php running in the normal way

MkDir failed (No such file or directory) in from_func.php on line 194

form_func.php is where im calling the following code which creates the folder

$currentdir= "/php/agents/greta/";
mkdir($currentdir, 0777);

that is the code.. i modified the $currentdir and kept it simple what was there before was $DOCUMENT_ROOT/php/agents/greta but that didnt work either

Can anyone help?

Thanks in Advance

sanj
 
Check to make sure that the entire path to the directory you want to create exists.

I notice also that you have a "/" at the beginning of your directory string. PHP's filesystem functions operate on the entire filesystem -- they are not constrained by the document root of the current virtual web server. So "/php/agents/greta" is relative to the root of your filesystem (or in the case of Win32, the current drive letter), no relative to your current document root. Want the best answers? Ask the best questions: TANSTAAFL!
 
hey there thanks

what i will do then is to put the whole path so that it knows where to go instead of assuming its relative thanks mate

will test it out and reply back if it does or doesnt succeed

cheers

sanj
 
you can make it relative by using the getcwd() fucntion.

This will give you the directory that your file is executing from

so you could do

$cur_dir=getcwd();
$$currentdir= $cur."/php/agents/greta/";
mkdir($currentdir, 0777);


Does that help? Reid Givens
Webdeveloper
 
You can use relative paths. Just keep in mind two things:[ul][li]the path is relative to the filesystem location of the script originally invoked by the web server (important to keep in mind if you are using filesystem commands from an included script in another location on the filesystem)[/li][li]when using relative paths, you should not use the initial &quot;/&quot; on the path -- this will reference the root of the filesystem or current drive letter. To create a directory named &quot;foo&quot;, which will be a subdirectory of the directory in which your script resides, issue &quot;mkdir ('foo', <some mode>)&quot;, not &quot;mkdir ('/foo', <some mode>)&quot;.[/li][/ul] Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top