townclown Posted June 11, 2008 Share Posted June 11, 2008 Hi, I am having an irritating issue when trying to check if exists/create a directory. Here is the code i am using: $dirname = "HE"; if (!is_dir("{$dirname}")) { print("Error: The directory <b>({$dirname})</b> doesn't exist"); mkdir("{$dirname}", 0777); print( " The directory {$dirname} has been successfully created."); } else { print "Directory Already Exists"; //more stuff to go in here } If the directory doesn't exist, it runs through the motions and creates it perfectly. My problem comes if the directory does exist, the browser opens the index of that directory instead of staying on the .php page that is running this script so anything in the else part( or anything that comes after the if statement) doesn't run. Any ideas? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Vizor Posted June 11, 2008 Share Posted June 11, 2008 Try using file_exists() instead of is_dir() also it might be a problem with whatever code is in your else block unless you're having problems with that basic script that you posted. Quote Link to comment Share on other sites More sharing options...
townclown Posted June 11, 2008 Author Share Posted June 11, 2008 Thanks, will try that; there is currently nothing in the else block other than the print. Quote Link to comment Share on other sites More sharing options...
townclown Posted June 11, 2008 Author Share Posted June 11, 2008 Same outcome with file_exists() Quote Link to comment Share on other sites More sharing options...
townclown Posted June 11, 2008 Author Share Posted June 11, 2008 Was an apache server setting btw Quote Link to comment 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.