一款php目录无限级创建代码

  1. */
  2. function makedirectory($directoryname) {
  3. $directoryname = str_replace("","/",$directoryname);
  4. $dirnames = explode('/', $directoryname);
  5. $total = count($dirnames) ;
  6. $temp = '';
  7. for($i=0; $i<$total; $i++) {
  8. $temp .= $dirnames[$i].'/';
  9. if (!is_dir($temp)) {
  10. $oldmask = umask(0);
  11. if (!mkdir($temp, 0777)) exit("不能建立目录 $temp");
  12. umask($oldmask);
  13. }
  14. }
  15. return true;
  16. }