Jump to content

[SOLVED] PHP 5 Creating Directory Issue


townclown

Recommended Posts

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.

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.