Jump to content

[SOLVED] mm not sure how to do this mkdirectory function work properly


shadiadiph

Recommended Posts

mm been thinking of an if statement that would work with this.

 

I have a page that creates a user upload directory on submit

 

mkdir("../secure/admin/clients/$username", 0700);

 

problem i have is if the user navigates backwards and submits a second time it produces an error

Warning: mkdir() [function.mkdir]: File exists in /home/apa/public_html/site/submit/isubmit.php on line 66

 

it writes the new files submitted to the folder ok but how can i stop it producing this error i was thinking of an if statement but can't think of how to word it??

 

in other words how can i check to see if a directory already exists on the server?

mm tried that still giving the same error

 

Warning: mkdir() [function.mkdir]: File exists in /home/apa/public_html/site/submit/isubmit.php on line 71

 

if(is_dir("../secure/admin/clients/$username") || is_file("../secure/admin/clients/$username")){
//dir already made
}
else
{
mkdir("../secure/admin/clients/$username", 0700);
}

 

 

a quick test on my server i had no problems im not sure what is happening.

that if should handle it

try putting

var_dump(is_dir("../secure/admin/clients/$username"));

var_dump(is_file("../secure/admin/clients/$username"));

to see what is going wrong i can't see any problems

 

Scott.

not sure but was kicking out that error just solved it seems to work with this though

 

if (file_exists("../secure/admin/clients/$username"))
{
}
else
{
mkdir("../secure/admin/clients/$username", 0700);
}

 

seems to work anyway thanks for the help

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.