Jump to content

How to a check if a folder exists, and if not make it?


ActaNonVerba1

Recommended Posts

Hey guys im automatically generating a folder location to place some image files the user has uploaded into.

 

If this folder doesnt exist how can i make it?

 

$target_path_thumbnails = "http://www.worldwidelighthouses.com/Images/".$folderlocation."/".$foldername."/Mini/";

Thats the path style.

 

:)

 

Danny

You must use an absolute path, not a URL.

$dir = '/home/html/images';
if(!is_dir($dir)) {
mkdir($dir,0777);
}

 

Hmm, i just made this.

 

Will do this do what i require?

 

// Where the thumbnail images will be placed
$target_path_thumbnails = "../../Images/".$folderlocation."/".$foldername."/Mini/";
if (file_exists($$target_path_thumbnails)) {
	//Do nothing.
} else {
	mkdir($target_path_thumbnails,0777);
}

 

:)

You must use an absolute path, not a URL.

$dir = '/home/html/images';
if(!is_dir($dir)) {
mkdir($dir,0777);
}

 

Hmm, i just made this.

 

Will do this do what i require?

 

// Where the thumbnail images will be placed
$target_path_thumbnails = "../../Images/".$folderlocation."/".$foldername."/Mini/";
if (file_exists($$target_path_thumbnails)) {
	//Do nothing.
} else {
	mkdir($target_path_thumbnails,0777);
}

 

:)

 

Ignoring the additional dollar sign which i have now deleted :P

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.