protected function getUnusedPath($path)
    {
        $newPath = $path;
        $info = pathinfo($path);
        $suffix = 1;
        while (file_exists($newPath)) {
            $newPath = $info['dirname'] . DIRECTORY_SEPARATOR . "{$info['filename']}_{$suffix}";
            if (isset($info['extension'])) {
                $newPath .= ".{$info['extension']}";
            }
            $suffix++;
        }
        return $newPath;
    }
protected function getUnusedPath($path)
    {
        $newPath = $path;
        $info = pathinfo($path);
        $suffix = 1;
        while (file_exists($newPath)) {
            $newPath = $info['dirname'] . DIRECTORY_SEPARATOR . "{$info['filename']}_{$suffix}";
            if (isset($info['extension'])) {
                $newPath .= ".{$info['extension']}";
            }
            $suffix++;
        }
        return $newPath;
    }
protected function getUnusedPath ( $ path ) { $ newPath = $ path ; $ info = pathinfo ( $ path ) ; $ suffix = 1 ; while ( file_exists ( $ newPath ) ) { $ newPath = $ info [ 'dirname' ] . DIRECTORY_SEPARATOR . "{$info['filename']}_{$suffix}" ; if ( isset ( $ info [ 'extension' ] ) ) { $ newPath .= ".{$info['extension']}" ; } $ suffix ++ ; } return $ newPath ; }
Returns an unused file path by adding a filename suffix if necessary.
@param string $path
@return string
Returns an unused file path by adding a filename suffix if necessary .