PHP--------folder file copy and copy

Source: Internet
Author: User

PHP is often used in the development of files, folders and files copy, copy and so on.

/** * Folder File copy * * @param string $src source folder * @param string $dst destination folder * @return bool*/functionDir_copy ($src= ",$DST= ' '){    if(Empty($src) ||Empty($DST))    {        return false; }     $dir=Opendir($src); Dir_mkdir ($DST);  while(false!== ($file=Readdir($dir)))    {        if(($file! = '. ') && ($file! = ' ... '))        {            if(Is_dir($src. ‘/‘ .$file) {dir_copy ($src. ‘/‘ .$file,$DST. ‘/‘ .$file); }            Else            {                Copy($src. ‘/‘ .$file,$DST. ‘/‘ .$file); }        }    }    Closedir($dir); return true;} /** * Create Folder * * @param string $path folder path * @param int $mode access rights * @param bool $recursive Whether to create recursively * @return BOOL*/functionDir_mkdir ($path= ",$mode= 0777,$recursive=true){    Clearstatcache(); if(!Is_dir($path))    {        mkdir($path,$mode,$recursive); return chmod($path,$mode); }     return true;}

PHP--------folder file copy and copy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.