File Exists Function

DescriptionWordpress snippet by - 05/27/10

In order to use the php file_exists() function you need the server root relative path. The wp_upload_dir() function provides the path to the uploads directory. You can then use that path in combination with many php functions to achive your goal. This snippet creates a new directory called "myNewDirectory" if it does not exist.

More InformationGoto Reference Page

Tags

$uploads = wp_upload_dir();
$wp_upload_directory = $uploads['basedir'];
//Check if quantum uploads exists and create
if (file_exists($wp_upload_directory . "/myNewDirectory")){
	//Do Nothing
} 
else {		 
	mkdir($wp_upload_directory . "/myNewDirectory", 0777);
}
  • Share
Authored by: Adam J Nowak
http://hyperspatial.com

Comments and Feedback