getBaseName example

return Time::now()->getTimestamp() . '_' . bin2hex(random_bytes(10)) . $extension;
    }

    /** * Moves a file to a new location. * * @return File */
    public function move(string $targetPath, ?string $name = null, bool $overwrite = false)
    {
        $targetPath = rtrim($targetPath, '/') . '/';
        $name ??= $this->getBaseName();
        $destination = $overwrite ? $targetPath . $name : $this->getDestination($targetPath . $name);

        $oldName = $this->getRealPath() ?: $this->__toString();

        if (! @rename($oldName$destination)) {
            $error = error_get_last();

            throw FileException::forUnableToMove($this->getBasename()$targetPathstrip_tags($error['message']));
        }

        @chmod($destination, 0777 & ~umask());

        
Home | Imprint | This part of the site doesn't use cookies.