Posted By

iloveitaly on 09/16/10


Tagged

path tree directory create


Versions (?)

Create Directory Path


 / Published in: PHP
 

  1. function create_path($targetPath) {
  2. $targetClimber = $targetPath;
  3.  
  4. while(!file_exists($targetPath)) {
  5. // if the 'climber' exists then reset to the top of the directory and drill down until we find a directory that doesn't exist
  6. if(file_exists($targetClimber)) {
  7. $targetClimber = $targetPath;
  8. } else if(file_exists(dirname($targetClimber))) {
  9. mkdir($targetClimber, 0775);
  10. } else {
  11. $targetClimber = dirname($targetClimber);
  12. }
  13. }
  14. }

Report this snippet  

You need to login to post a comment.