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

Link to comment
Share on other sites

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);
}

 

:)

Link to comment
Share on other sites

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

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.