topcoder1 Posted July 15, 2008 Share Posted July 15, 2008 given a path, I want to check to see if a directory exists, then create one if it doesn't. dir(path) gives an error: [function.dir]: failed to open dir: Invalid argument . Are there functions allow me to do all those? thanks Quote Link to comment https://forums.phpfreaks.com/topic/114938-check-to-see-if-a-directory-exists/ Share on other sites More sharing options...
MadTechie Posted July 16, 2008 Share Posted July 16, 2008 try this <?php $dir = "path/to/folder"; if( !(file_exists($dir) && is_dir($dir)) ) { mkdir($dir, 0700); } ?> PS file_exists check files and folders Quote Link to comment https://forums.phpfreaks.com/topic/114938-check-to-see-if-a-directory-exists/#findComment-591140 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.