Advertisement
Guest User

Create Directory

a guest
Jul 25th, 2012
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.42 KB | None | 0 0
  1. <?php
  2. try{
  3.     if(file_exists("files/$username")){
  4.         $rand = substr(md5(microtime()),rand(0,26),5);
  5.         if(mkdir("files/$username.$rand", 0777))
  6.         {
  7.             return true;
  8.         }else{
  9.             throw new Exception('Cant create directory');
  10.         }
  11.     }else{
  12.         if(mkdir("files/$username", 0777))
  13.         {
  14.             return true;
  15.         }else{
  16.             throw new Exception('Cant create directory');
  17.         }
  18.     }
  19. }catch(Exception $e){
  20.     echo $e->getMessage();
  21. }
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement