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

objective c - iPhone and it's wireless area -

unix - Listing all shared memory segments used by a process on AIX5.3+ -

tsql - Correct sql/hql query (aggregate in where clause) -