Create Directory Path


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.