src/Utils/Filesystem.php
public function rename($filename, $newname, $try_another_name = false)
    {
        // Verificar se deve tentar outro nome caso ja exista
        if ($try_another_name)
        {
            $file_mask = preg_replace('/(.[a-zA-Z0-9]+)$/', '_%s\1', $filename);
            $contador = 1;
            while ($this->exists($newname))
            {
                $newname = sprintf($file_mask, $contador);
                $contador += 1;
            }
        }

        $this->copy($filename, $newname);
        $this->delete($filename);

        return $newname;
    }
public function rename($filename, $newname, $try_another_name = false)
    {
        // Verificar se deve tentar outro nome caso ja exista
        if ($try_another_name)
        {
            $file_mask = preg_replace('/(.[a-zA-Z0-9]+)$/', '_%s\1', $filename);
            $contador = 1;
            while ($this->exists($newname))
            {
                $newname = sprintf($file_mask, $contador);
                $contador += 1;
            }
        }

        $this->copy($filename, $newname);
        $this->delete($filename);

        return $newname;
    }
public function rename ( $ filename , $ newname , $ try_another_name = false ) { // Verificar se deve tentar outro nome caso ja exista if ( $ try_another_name ) { $ file_mask = preg_replace ( '/(.[a-zA-Z0-9]+)$/' , '_%s\1' , $ filename ) ; $ contador = 1 ; while ( $ this -> exists ( $ newname ) ) { $ newname = sprintf ( $ file_mask , $ contador ) ; $ contador += 1 ; } } $ this -> copy ( $ filename , $ newname ) ; $ this -> delete ( $ filename ) ; return $ newname ; }
Rename file with option of make new filename
@return string
Rename file with option of make new filename