How to test if a directory already exist in PHP? -


How can I test if a directory already exists and if none in PHP is created?

Try this:

  $ filename = "/ tmp"; If (! File_exists ($ filename)) echo $ filename, "does not exist"; Elseif (! Is_dir ($ filename)) echo $ filename, "no directory"; Else "Directory" echo, $ filename, "already exists"; Check if path / file exists and  is_dir  checks whether the given file name directory is or not. 

Edit:

To create a directory later, call

  mkdir ($ filename);  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -