for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Author: Ivo Toman
*/
namespace h4kuna\Upload\Upload;
use Nette\Http;
class SanitizedFileName implements IFileName
{
protected $called = 0;
* @param Http\FileUpload $fileUpload
* @return string
public function createUniqueName(Http\FileUpload $fileUpload)
$name = $fileUpload->getSanitizedName();
//if we call moretimes, name is not unique, generate another one
if($this->called !== 0) {
$parts = pathinfo($name);
$name = $parts['filename'] . $this->called . '.' . $parts['extension'];
}
$this->called++;
return $name;