protected function findTargetFilename($target)
    {
        //If the file already exists, adds a numeric suffix
        if (file_exists($target)) {
            $dirname = dirname($target) . DS;
            $filename = pathinfo($target, PATHINFO_FILENAME);
            $extension = pathinfo($target, PATHINFO_EXTENSION);

            //Initial tmp name
            $tmp = $dirname . $filename;

            for ($i = 1;; $i++) {
                $target = $tmp . '_' . $i;

                if ($extension) {
                    $target .= '.' . $extension;
                }

                if (!file_exists($target)) {
                    break;
                }
            }
        }

        return $target;
    }
protected function findTargetFilename($target)
    {
        //If the file already exists, adds a numeric suffix
        if (file_exists($target)) {
            $dirname = dirname($target) . DS;
            $filename = pathinfo($target, PATHINFO_FILENAME);
            $extension = pathinfo($target, PATHINFO_EXTENSION);

            //Initial tmp name
            $tmp = $dirname . $filename;

            for ($i = 1;; $i++) {
                $target = $tmp . '_' . $i;

                if ($extension) {
                    $target .= '.' . $extension;
                }

                if (!file_exists($target)) {
                    break;
                }
            }
        }

        return $target;
    }
protected function findTargetFilename ( $ target ) { //If the file already exists, adds a numeric suffix if ( file_exists ( $ target ) ) { $ dirname = dirname ( $ target ) . DS ; $ filename = pathinfo ( $ target , PATHINFO_FILENAME ) ; $ extension = pathinfo ( $ target , PATHINFO_EXTENSION ) ; //Initial tmp name $ tmp = $ dirname . $ filename ; for ( $ i = 1 ; ; $ i ++ ) { $ target = $ tmp . '_' . $ i ; if ( $ extension ) { $ target .= '.' . $ extension ; } if ( ! file_exists ( $ target ) ) { break ; } } } return $ target ; }
Internal method to find the target filename
@param string $target Path
@return string
Internal method to find the target filename