public function move($path, $overwrite = false) {
        $path = str_replace('\\', '/', $path);

        if (substr($path, -1) !== '/') {
            $path .= '/';
        }

        // Don't move to the same folder
        if (realpath($path) === realpath($this->dir())) {
            return true;
        }

        if (!file_exists($path)) {
            mkdir($path, 0777, true);

        } else if (!is_writable($path)) {
            chmod($path, 0777);
        }

        // Determine name and overwrite
        $name = $this->name();
        $ext = $this->ext();

        if (!$overwrite) {
            $no = 1;

            while (file_exists($path . $name . '.' . $ext)) {
                $name = $this->name() . '-' . $no;
                $no++;
            }
        }

        // Move the file
        $targetPath = $path . $name . '.' . $ext;

        if (rename($this->path(), $targetPath)) {
            $this->reset($targetPath);

            return true;
        }

        return false;
    }
public function move($path, $overwrite = false) {
        $path = str_replace('\\', '/', $path);

        if (substr($path, -1) !== '/') {
            $path .= '/';
        }

        // Don't move to the same folder
        if (realpath($path) === realpath($this->dir())) {
            return true;
        }

        if (!file_exists($path)) {
            mkdir($path, 0777, true);

        } else if (!is_writable($path)) {
            chmod($path, 0777);
        }

        // Determine name and overwrite
        $name = $this->name();
        $ext = $this->ext();

        if (!$overwrite) {
            $no = 1;

            while (file_exists($path . $name . '.' . $ext)) {
                $name = $this->name() . '-' . $no;
                $no++;
            }
        }

        // Move the file
        $targetPath = $path . $name . '.' . $ext;

        if (rename($this->path(), $targetPath)) {
            $this->reset($targetPath);

            return true;
        }

        return false;
    }
public function move ( $ path , $ overwrite = false ) { $ path = str_replace ( '\\' , '/' , $ path ) ; if ( substr ( $ path , - 1 ) !== '/' ) { $ path .= '/' ; } // Don't move to the same folder if ( realpath ( $ path ) === realpath ( $ this -> dir ( ) ) ) { return true ; } if ( ! file_exists ( $ path ) ) { mkdir ( $ path , 0777 , true ) ; } else if ( ! is_writable ( $ path ) ) { chmod ( $ path , 0777 ) ; } // Determine name and overwrite $ name = $ this -> name ( ) ; $ ext = $ this -> ext ( ) ; if ( ! $ overwrite ) { $ no = 1 ; while ( file_exists ( $ path . $ name . '.' . $ ext ) ) { $ name = $ this -> name ( ) . '-' . $ no ; $ no ++ ; } } // Move the file $ targetPath = $ path . $ name . '.' . $ ext ; if ( rename ( $ this -> path ( ) , $ targetPath ) ) { $ this -> reset ( $ targetPath ) ; return true ; } return false ; }
Move the file to a new directory.
If a file with the same name already exists, either overwrite or increment file name.

@param string $path
@param bool $overwrite
@return bool
Move the file to a new directory . If a file with the same name already exists either overwrite or increment file name .