shadiadiph Posted February 19, 2009 Share Posted February 19, 2009 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? Link to comment https://forums.phpfreaks.com/topic/145881-solved-mm-not-sure-how-to-do-this-mkdirectory-function-work-properly/ Share on other sites More sharing options...
ratcateme Posted February 19, 2009 Share Posted February 19, 2009 if(is_dir("../secure/admin/clients/$username") || is_file("../secure/admin/clients/$username")){ //dir already made } try that Scott. Link to comment https://forums.phpfreaks.com/topic/145881-solved-mm-not-sure-how-to-do-this-mkdirectory-function-work-properly/#findComment-765903 Share on other sites More sharing options...
shadiadiph Posted February 19, 2009 Author Share Posted February 19, 2009 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); } Link to comment https://forums.phpfreaks.com/topic/145881-solved-mm-not-sure-how-to-do-this-mkdirectory-function-work-properly/#findComment-765907 Share on other sites More sharing options...
ratcateme Posted February 19, 2009 Share Posted February 19, 2009 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. Link to comment https://forums.phpfreaks.com/topic/145881-solved-mm-not-sure-how-to-do-this-mkdirectory-function-work-properly/#findComment-765913 Share on other sites More sharing options...
shadiadiph Posted February 19, 2009 Author Share Posted February 19, 2009 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 Link to comment https://forums.phpfreaks.com/topic/145881-solved-mm-not-sure-how-to-do-this-mkdirectory-function-work-properly/#findComment-765917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.