src/File/FileUtil.php
public function addUniqueIdToFilename($fileName, $prefix = null, $moreEntropy = true)
    {
        $file = new File($fileName);

        $directory = ltrim(str_replace($this->container->getParameter('kernel.project_dir'), '', $file->dirname), '/');

        return ($directory ? $directory.'/' : '').$file->filename.uniqid($prefix, $moreEntropy).($file->extension ? '.'
                                                                                                                            .$file->extension : '');
    }
public function addUniqueIdToFilename($fileName, $prefix = null, $moreEntropy = true)
    {
        $file = new File($fileName);

        $directory = ltrim(str_replace($this->container->getParameter('kernel.project_dir'), '', $file->dirname), '/');

        return ($directory ? $directory.'/' : '').$file->filename.uniqid($prefix, $moreEntropy).($file->extension ? '.'
                                                                                                                            .$file->extension : '');
    }
public function addUniqueIdToFilename ( $ fileName , $ prefix = null , $ moreEntropy = true ) { $ file = new File ( $ fileName ) ; $ directory = ltrim ( str_replace ( $ this -> container -> getParameter ( 'kernel.project_dir' ) , '' , $ file -> dirname ) , '/' ) ; return ( $ directory ? $ directory . '/' : '' ) . $ file -> filename . uniqid ( $ prefix , $ moreEntropy ) . ( $ file -> extension ? '.' . $ file -> extension : '' ) ; }
Add a unique identifier to a file name.

@param string $fileName    The file name, can be with or without path
@param string $prefix      add a prefix to the unique identifier, with an empty prefix, the returned string will be 13 characters long
@param bool   $moreEntropy if set to TRUE, will add additional entropy (using the combined linear congruential generator) at the end of the
return value, which increases the likelihood that the result will be unique

@return string Filename with timestamp based unique identifier
Add a unique identifier to a file name .