Create Folder On Server Upon Registration

后端 未结 4 1395
借酒劲吻你
借酒劲吻你 2021-01-15 16:40

I wonder whether someone could help me please.

I\'ve been trying to find a tutorial or examples of how to automatically create a folder in my server upon \'user regi

相关标签:
4条回答
  • 2021-01-15 17:19

    To create folders with php you can use the function mkdir (which stands for "make directory").

    http://php.net/manual/de/function.mkdir.php

    0 讨论(0)
  • 2021-01-15 17:22

    It's basically making use of mkdir, however you might want to wrap this into a class of it's own so you can later on better bind it to a user-name or ID to move away from concrete pathnames:

    $userDir = new UserDir($pathToUserDir);
    $userDir->createImageDirectory();
    
    class UserDir extends SplFileInfo
    {
        public function createThumbDirectory()
        {
            return $this->createSubdirectory('thumb');
        }
        public function createImageDirectory()
        {
            return $this->createSubdirectory('image');
        }
        private function createSubdirectory($name)
        {
            $path = $this->getPathname();
            $dir = $path . PATH_SEPARATOR . $name;
            return mkdir($dir);
        }
    }
    

    You can then extend this with error condition checking in a central place, so it's easy to use in your application.

    0 讨论(0)
  • 2021-01-15 17:28

    You could use something like exec() to run a system command like mkdir http://php.net/manual/en/function.exec.php

    0 讨论(0)
  • 2021-01-15 17:30

    use mkdir.
    source: http://php.net/manual/en/function.mkdir.php complete description given

    0 讨论(0)
提交回复
热议问题