public function moveTo($dst, $allowedExtensions = 'jpg,jpeg,png,gif,doc,xls,pdf,zip', $overwrite = false)
    {
        if ($allowedExtensions !== '*') {
            $extension = pathinfo($dst, PATHINFO_EXTENSION);
            if (!$extension || preg_match("#\b$extension\b#", $allowedExtensions) !== 1) {
                throw new FileException(['`:extension` file type is not allowed upload', 'extension' => $extension]);
            }
        }

        if ($this->_file['error'] !== UPLOAD_ERR_OK) {
            throw new FileException(['error code of upload file is not UPLOAD_ERR_OK: :error', 'error' => $this->_file['error']]);
        }

        if ($this->filesystem->fileExists($dst)) {
            if ($overwrite) {
                $this->filesystem->fileDelete($dst);
            } else {
                throw new FileException(['`:file` file already exists', 'file' => $dst]);
            }
        }

        $this->filesystem->dirCreate(dirname($dst));

        if (!move_uploaded_file($this->_file['tmp_name'], $this->alias->resolve($dst))) {
            throw new FileException(['move_uploaded_file to `:dst` failed: :last_error_message', 'dst' => $dst]);
        }

        if (!chmod($this->alias->resolve($dst), 0644)) {
            throw new FileException(['chmod `:dst` destination failed: :last_error_message', 'dst' => $dst]);
        }
    }
public function moveTo($dst, $allowedExtensions = 'jpg,jpeg,png,gif,doc,xls,pdf,zip', $overwrite = false)
    {
        if ($allowedExtensions !== '*') {
            $extension = pathinfo($dst, PATHINFO_EXTENSION);
            if (!$extension || preg_match("#\b$extension\b#", $allowedExtensions) !== 1) {
                throw new FileException(['`:extension` file type is not allowed upload', 'extension' => $extension]);
            }
        }

        if ($this->_file['error'] !== UPLOAD_ERR_OK) {
            throw new FileException(['error code of upload file is not UPLOAD_ERR_OK: :error', 'error' => $this->_file['error']]);
        }

        if ($this->filesystem->fileExists($dst)) {
            if ($overwrite) {
                $this->filesystem->fileDelete($dst);
            } else {
                throw new FileException(['`:file` file already exists', 'file' => $dst]);
            }
        }

        $this->filesystem->dirCreate(dirname($dst));

        if (!move_uploaded_file($this->_file['tmp_name'], $this->alias->resolve($dst))) {
            throw new FileException(['move_uploaded_file to `:dst` failed: :last_error_message', 'dst' => $dst]);
        }

        if (!chmod($this->alias->resolve($dst), 0644)) {
            throw new FileException(['chmod `:dst` destination failed: :last_error_message', 'dst' => $dst]);
        }
    }
public function moveTo ( $ dst , $ allowedExtensions = 'jpg,jpeg,png,gif,doc,xls,pdf,zip' , $ overwrite = false ) { if ( $ allowedExtensions !== '*' ) { $ extension = pathinfo ( $ dst , PATHINFO_EXTENSION ) ; if ( ! $ extension || preg_match ( "#\b$extension\b#" , $ allowedExtensions ) !== 1 ) { throw new FileException ( [ '`:extension` file type is not allowed upload' , 'extension' => $ extension ] ) ; } } if ( $ this -> _file [ 'error' ] !== UPLOAD_ERR_OK ) { throw new FileException ( [ 'error code of upload file is not UPLOAD_ERR_OK: :error' , 'error' => $ this -> _file [ 'error' ] ] ) ; } if ( $ this -> filesystem -> fileExists ( $ dst ) ) { if ( $ overwrite ) { $ this -> filesystem -> fileDelete ( $ dst ) ; } else { throw new FileException ( [ '`:file` file already exists' , 'file' => $ dst ] ) ; } } $ this -> filesystem -> dirCreate ( dirname ( $ dst ) ) ; if ( ! move_uploaded_file ( $ this -> _file [ 'tmp_name' ] , $ this -> alias -> resolve ( $ dst ) ) ) { throw new FileException ( [ 'move_uploaded_file to `:dst` failed: :last_error_message' , 'dst' => $ dst ] ) ; } if ( ! chmod ( $ this -> alias -> resolve ( $ dst ) , 0644 ) ) { throw new FileException ( [ 'chmod `:dst` destination failed: :last_error_message' , 'dst' => $ dst ] ) ; } }
Moves the temporary file to a destination within the application

@param string $dst
@param string $allowedExtensions
@param bool   $overwrite

@throws \ManaPHP\Http\Request\File\Exception
Moves the temporary file to a destination within the application