Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home PHP PHP check if folder exists then create folder

PHP check if folder exists then create folder

This example below will check if a folder/directory is existed or not by using PHP is_dir function, if not will create that folder/directory by using PHP mkdir function

 

 

 

 

[php] <?php
$ABSPATH = dirname(__FILE__) . ‘/’;

$folder_name = "your-new-folder";

$new_folder_path = $ABSPATH . $folder_name;

if(!is_dir($new_folder_path))
{
mkdir($new_folder_path);
echo "The directory " . $folder_name . " was successfully created.";
}
else
{
echo "The directory " . $folder_name . " was existed.";
}
?>
[/php]

Note: the mode is 0777 by default, which means the widest possible access. mode is ignored on Windows

Mar 6, 2011Hoan Huynh
Linux CentOS view live website access log with tail commandPHP display all errors and warnings
You Might Also Like:
  • How To Track Website With Multiple Google Analytisc Accounts
  • Facebook Like Button And Recommend Button With fb:like, iframe and html5
  • Create Count Down Download Page With JavaScript
  • PHP Copy Entire Directory To Another Directory
  • Get Image Width Height With JQuery And JavaScript
  • Javascript Problem Set focus textbox on Firefox
  • Jquery checkbox checked
  • Configure To Run Codeigniter In Sub Folder Or Sub Directory
  • JavaScript Get Radio Button Value
  • PHP Completely Delete A Directory Include Sub Directories And Files
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

10 years ago PHPdirname, is_dir, mkdir346
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
22,237 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
20,087 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
15,872 views
JQuery Allow only numeric characters or only alphabet characters in textbox
13,343 views
C# Read Json From URL And Parse/Deserialize Json
9,851 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Term Papers – Easy to Take Care of
  • How to Write Term Papers in Online Tutorials
  • How to Plan Writing an Essay
  • How to Apply For a Payday Loan With Bad Credit
  • Statistics For Sale – How To Compose One
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (28)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (123)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development