src/Bundle/Common/File/FileUpload.php
public function move(string $directory, string $name = ''): File
    {
        if ($this->isValid()) {
            $target = $this->getTargetFile($directory, $name);

            if (!@move_uploaded_file($this->getPathname(), $target)) {
                $error = error_get_last();
                throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
            }

            $this->customChmod($target);

            return $target;
        }

        throw new FileException($this->errorMessage());
    }
public function move(string $directory, string $name = ''): File
    {
        if ($this->isValid()) {
            $target = $this->getTargetFile($directory, $name);

            if (!@move_uploaded_file($this->getPathname(), $target)) {
                $error = error_get_last();
                throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, strip_tags($error['message'])));
            }

            $this->customChmod($target);

            return $target;
        }

        throw new FileException($this->errorMessage());
    }
public function move ( string $ directory , string $ name = '' ) : File { if ( $ this -> isValid ( ) ) { $ target = $ this -> getTargetFile ( $ directory , $ name ) ; if ( ! @ move_uploaded_file ( $ this -> getPathname ( ) , $ target ) ) { $ error = error_get_last ( ) ; throw new FileException ( sprintf ( 'Could not move the file "%s" to "%s" (%s)' , $ this -> getPathname ( ) , $ target , strip_tags ( $ error [ 'message' ] ) ) ) ; } $ this -> customChmod ( $ target ) ; return $ target ; } throw new FileException ( $ this -> errorMessage ( ) ) ; }
Moves the file to a new location.

@param string $directory Destination folder
@param string $name      New file name
@return File A File object representing the new file
@throws FileException
Moves the file to a new location .