app/File.php
public function copy($dest)
    {

        // La source n'existe pas
        if (!file_exists($this->path)) {
            throw new \Exception("Source don't exist : " . $this->path, 1);
        }

        // La destination ne doit pas exister.
        if (file_exists($dest)) {
            throw new \Exception("Destination already exist : $dest", 1);
        }

        if (is_file($this->path)) {
            // Copie d'un fichier dans un dossier.
            if (is_dir($dest)) {
                $dest = $this->addSlash($dest) . basename($this->path);
            }
            copy($this->path, $dest);
            return;
        }

        $dest = $this->addSlash($dest);

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator(
                $this->path,
                \RecursiveDirectoryIterator::SKIP_DOTS
            )
        );
        foreach ($iterator as $path => $file) {
            $fileDest = $dest . $iterator->getSubPathName();
            if (!file_exists(dirname($fileDest))) {
                mkdir(dirname($fileDest), 0777, true);
            }
            copy($path, $fileDest);
        }
    }
public function copy($dest)
    {

        // La source n'existe pas
        if (!file_exists($this->path)) {
            throw new \Exception("Source don't exist : " . $this->path, 1);
        }

        // La destination ne doit pas exister.
        if (file_exists($dest)) {
            throw new \Exception("Destination already exist : $dest", 1);
        }

        if (is_file($this->path)) {
            // Copie d'un fichier dans un dossier.
            if (is_dir($dest)) {
                $dest = $this->addSlash($dest) . basename($this->path);
            }
            copy($this->path, $dest);
            return;
        }

        $dest = $this->addSlash($dest);

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator(
                $this->path,
                \RecursiveDirectoryIterator::SKIP_DOTS
            )
        );
        foreach ($iterator as $path => $file) {
            $fileDest = $dest . $iterator->getSubPathName();
            if (!file_exists(dirname($fileDest))) {
                mkdir(dirname($fileDest), 0777, true);
            }
            copy($path, $fileDest);
        }
    }
public function copy ( $ dest ) { // La source n'existe pas if ( ! file_exists ( $ this -> path ) ) { throw new \ Exception ( "Source don't exist : " . $ this -> path , 1 ) ; } // La destination ne doit pas exister. if ( file_exists ( $ dest ) ) { throw new \ Exception ( "Destination already exist : $dest" , 1 ) ; } if ( is_file ( $ this -> path ) ) { // Copie d'un fichier dans un dossier. if ( is_dir ( $ dest ) ) { $ dest = $ this -> addSlash ( $ dest ) . basename ( $ this -> path ) ; } copy ( $ this -> path , $ dest ) ; return ; } $ dest = $ this -> addSlash ( $ dest ) ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ this -> path , \ RecursiveDirectoryIterator :: SKIP_DOTS ) ) ; foreach ( $ iterator as $ path => $ file ) { $ fileDest = $ dest . $ iterator -> getSubPathName ( ) ; if ( ! file_exists ( dirname ( $ fileDest ) ) ) { mkdir ( dirname ( $ fileDest ) , 0777 , true ) ; } copy ( $ path , $ fileDest ) ; } }
Copy this file to destination
@param  [type] $destination [description]
@return [type]          [description]
Copy this file to destination