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
https://forums.phpfreaks.com/topic/109723-solved-php-5-creating-directory-issue/
Share on other sites

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.