public function uniqueFilename($data)
	{
		$filename = $this->automaticFilename($data);

		if (file_exists($this->getUploadDir() . DS . $data['comment_id'] . DS . $filename))
		{
			$ext = strrchr($filename, '.');
			$prefix = substr($filename, 0, -strlen($ext));

			$i = 1;

			while (is_file($this->getUploadDir() . DS . $data['comment_id'] . DS . $filename))
			{
				$filename = $prefix . ++$i . $ext;
			}
		}

		$data['filename'] = $filename;

		return $data['filename'];
	}
public function uniqueFilename($data)
	{
		$filename = $this->automaticFilename($data);

		if (file_exists($this->getUploadDir() . DS . $data['comment_id'] . DS . $filename))
		{
			$ext = strrchr($filename, '.');
			$prefix = substr($filename, 0, -strlen($ext));

			$i = 1;

			while (is_file($this->getUploadDir() . DS . $data['comment_id'] . DS . $filename))
			{
				$filename = $prefix . ++$i . $ext;
			}
		}

		$data['filename'] = $filename;

		return $data['filename'];
	}
public function uniqueFilename ( $ data ) { $ filename = $ this -> automaticFilename ( $ data ) ; if ( file_exists ( $ this -> getUploadDir ( ) . DS . $ data [ 'comment_id' ] . DS . $ filename ) ) { $ ext = strrchr ( $ filename , '.' ) ; $ prefix = substr ( $ filename , 0 , - strlen ( $ ext ) ) ; $ i = 1 ; while ( is_file ( $ this -> getUploadDir ( ) . DS . $ data [ 'comment_id' ] . DS . $ filename ) ) { $ filename = $ prefix . ++ $ i . $ ext ; } } $ data [ 'filename' ] = $ filename ; return $ data [ 'filename' ] ; }
Ensure no conflicting file names by
renaming the incoming file if the name
already exists

@param   array  $data
@return  string
Ensure no conflicting file names by renaming the incoming file if the name already exists