protected function saveFile($uploadedFile)
    {
        $ext = $this->getExt();
        $fullExt = $ext ? '.' . $ext : '';

        if ($this->fileName) {
            $fileName = $this->fileName;
        } else {
            $fileName = substr($uploadedFile['name'], 0, strlen($uploadedFile['name']) - strlen($fullExt));
        }

        $this->file = $this->dir . '/' . $fileName . $fullExt;
        if (!$this->overwrite) {
            $i = 1;
            while(is_file($this->file)) {
                $this->file = $this->dir . '/' . $fileName . '-' . $i . $fullExt;
                $i++;
            }
        }

        if (!$this->moveUploadedFile($uploadedFile['tmp_name'], $this->file)) {
            $this->addError('cantMove');
            return false;
        }

        return true;
    }