Utorzenie kopii plików dla tego uploadera
@return boolean
193905
protected function _createTempFiles()
    {
        //jeśli już są pliki tymczasowe, to wychodzimy
        if ((new \Cms\Orm\CmsFileQuery)
            ->byObject('tmp-' . $this->getUploaderObject(), $this->getUploaderId())
            ->count()) {
            return true;
        }
        $objectId = null;
        if ($this->_form->hasRecord()) {
            $objectId = $this->_form->getRecord()->getPk();
        }
        //tworzymy pliki tymczasowe - linki do oryginałów
        \Cms\Model\File::link($this->getUploaderObject(), $objectId, 'tmp-' . $this->getUploaderObject(), $this->getUploaderId());
        return true;
    }
1011625
public function beforeSave()
    {
        //brak loginu lub hasła
        if (!$this->getElement('username')->getValue() || !$this->getElement('password')->getValue()) {
            return false;
        }
        //autoryzacja
        $auth = \App\Registry::$auth;
        \App\Registry::$auth->setIdentity($this->getElement('username')->getValue());
        \App\Registry::$auth->setCredential($this->getElement('password')->getValue());
        return \App\Registry::$auth->authenticate();
    }
776878
public function transport(){

            $target = ($this->target === "") ? "":$this->target."/";
            $targetFileName = sprintf('%s%s.%s', $target, $this->newName, $this->ext);

            // eğer dosya varsa siler
            if(file_exists($targetFileName)){
                unlink($targetFileName);
            }


            if(move_uploaded_file($this->file['tmp_name'], $targetFileName)){
                chmod($targetFileName, 0777);
                return $targetFileName;
            }else{
                return false;
            }
        }
377725
public function imageupload(){
		if (!Member::currentUserID()) {
			$return = array(
				'error' => 1,
				'text' => "Cannot upload there"
			);
			return Convert::raw2json($return);
		}
		if(isset($_FILES['NewImage']) && $tempfile = $_FILES['NewImage']){
			// validate //
			
			$allowed = array('jpg', 'jpeg', 'gif', 'png', 'ico');
			$nameBits = explode('.', $tempfile['name']);
			$ext = end($nameBits);
			if(!in_array(strtolower($ext), $allowed)){
				$return = array(
					'error' => 1,
					'text' => "Your image must be in jpg, gif or png format"
				);
				return Convert::raw2json($return);
			}
			
			$maxsize = $_POST['MAX_FILE_SIZE'];
			if($tempfile['size'] > $maxsize){
				$size = number_format($maxsize / 1024 / 1024, 2) . 'MB'; 
				$return = array(
					'error' => 1,
					'text' => "Your image must be smaller than $size"
				);
				return Convert::raw2json($return);
			}
			
			// upload //
			
			$upload	= new Upload;
			$file = new Image();
			$upload->loadIntoFile($tempfile, $file);
			if($upload->isError()) 
				return false;
			$file = $upload->getFile();
			$return =  array(
				'link' => $file->Link()
			);
			return Convert::raw2json($return);
		
		}else{
		 	// no file to upload
			return false;
		}
	}
1151923
public function getIsMultiUpload()
    {
        if (isset($this->multiUpload)) {
            return $this->multiUpload;
        }
        // Guess from record
        $record = $this->getRecord();
        $name = $this->getName();

        // Disabled for has_one components
        if ($record && DataObject::getSchema()->hasOneComponent(get_class($record), $name)) {
            return false;
        }
        return true;
    }
1207776
public function save()
    {
        if ($this->validate() && $this->file instanceof UploadedFile) {
            try {
                if (($uploader = $this->file->save()) != false) {
                    $this->file = $uploader->getUrl();
                    return true;
                } else {
                    $this->addError('file', Yii::t('yuncms', 'Audio file storage failed.'));
                }
            } catch (FileExistsException $e) {
                $this->addError('file', $e->getMessage());
            } catch (ErrorException $e) {
                $this->addError('file', $e->getMessage());
            } catch (InvalidConfigException $e) {
                $this->addError('file', $e->getMessage());
            }
        }
        return false;
    }
804266
public function doUpload()
    {
        $disk = \Storage::disk($this->getOption('disk'));
        $file = \Input::file('file');

        $ext = $file->getClientOriginalExtension() ?: $file->guessClientExtension();

        $filename = md5_file($file->getRealPath()).'.'.$ext;
        $put_path = trim($this->getOption('path'), ' /').'/'.$filename;

        if (!$disk->exists($put_path)) {
            $f_res = fopen($file->getRealPath(), 'r');
            $disk->put($put_path, $f_res);
            fclose($f_res);
        }

        return [
            'errors'        => [],
            'path'          => trim($put_path, '/'),
            'filename'      => trim($put_path, '/'),
            'original_name' => $file->getClientOriginalName(),
        ];
    }
1147008
public function afterSave()
    {
        //brak filtra
        if (!$this->getElement('fileObjects')) {
            return false;
        }
        //wczytywanie sesji
        $session = new \Mmi\Session\SessionSpace(\Cms\Model\ConnectorModel::SESSION_SPACE);
        try {
            //pobranie plików z connectora
            $remoteFiles = (new \Cms\Model\ConnectorModel)->getData($session->url, 'exportFileList', ['fileObjects' => $this->getElement('fileObjects')->getValue()], $session->identity, $session->credential);
        } catch (\Cms\Exception\ConnectorException $e) {
            //brak plików
            $this->getElement('fileObjects')->addError('form.connectorImportFilesForm.fileObjects.error.empty');
            return false;
        }
        $files = [];
        foreach ($remoteFiles as $name => $userName) {
            if (null !== (new \Cms\Orm\CmsFileQuery)->whereName()->equals($name)->findFirst()) {
                continue;
            }
            $files[$name] = $userName;
        }
        //ustawienie danych na elementy pobrane z connectora
        $this->setOption('data', $files);
        return true;
    }
77744
public function validate()
    {
        $multipleUploads = false;
        if (strval($this->multiple) != '') {
            $field = str_replace('[]', '', $this->name);
            if (isset($_FILES[$field]['name'][0]) && strlen($_FILES[$field]['name'][0]) > 0) {
                $multipleUploads = true;
            }
        }

        if (!$this->checkValue($multipleUploads)) {
            return false;
        }

        $validator = $this->getValidator();
        $this->callValidator($validator);

        if ($this->customError) {
            return false;
        }

        return true;
    }
1334607
protected function _validateUpload() : bool
    {
        if (! $this->request->getData('file')) {
            $this->flash->error('Please choose a file to upload.');

            return false;
        }

        if (! in_array($this->request->getData('file.type'), $this->__supportedMimeTypes)) {
            $this->flash->error('Unable to upload file, unsupported file provided.');

            return false;
        }

        return true;
    }
979146
protected function _createTempFiles()
    {
        //jeśli już są pliki tymczasowe, to wychodzimy
        if ((new \Cms\Orm\CmsFileQuery)
                ->byObject($this->_tempObject, $this->getUploaderId())
                ->count()) {
            return true;
        }
        //tworzymy pliki tymczasowe - kopie oryginałów
        \Cms\Model\File::link($this->_object, $this->_objectId, $this->_tempObject, $this->getUploaderId());
        return true;
    }
1243908
public function isValid()
    {
        $isOk = $this->error === UPLOAD_ERR_OK;

        return $this->test ? $isOk : $isOk && is_uploaded_file($this->getPathname());
    }
280516
public function validateAction()
    {
        //typ odpowiedzi: plain
        $this->getResponse()->setTypePlain();
        //wyłączenie layoutu
        $this->view->setLayoutDisabled();

        //sprawdzenie obecności obowiązkowych pól w poscie
        if (!$this->getPost()->class || !$this->getPost()->field) {
            return '';
        }
        //nazwa klasy forma
        $className = $this->getPost()->class;
        //klasa rekordu
        $recordClassName = $this->getPost()->recordClass;
        //powoływanie forma
        $form = new $className($recordClassName ? new $recordClassName($this->getPost()->recordId ? $this->getPost()->recordId : null) : null);
        /* @var $form \Mmi\Form\Form */
        //pobieranie elementu do walidacji
        $element = $form->getElement($this->getPost()->field);
        //jeśli brak elementu - wyjście
        if (!$element instanceof \Mmi\Form\Element\ElementAbstract) {
            return '';
        }
        //ustawienie wartości elementu
        $element->setValue(urldecode($this->getPost()->value));
        //walidacja i zwrot wyniku
        if (!$element->isValid()) {
            $this->view->errors = $element->getErrors();
            return;
        }
        //poprawna walidacja
        return '';
    }
926071
public function isAllowed()
    {
		//jeśli brak dostępu do aktualnej kategorii
		if (!$this->_checkAccess($this->_category->id)) {
			return false;
		}
		//jeśli brak dostępu do któregoś rodzica
		if (!$this->_checkParents()) {
			return false;
		}
        return true;
    }
874665
public function save()
    {
        //próba wstawienia - częstsza operacja
        try {
            //insert
            return $this->_insert();
        } catch (DbException $e) {
            //próba aktualizacji
            try {
                //update
                return $this->_update();
            } catch (DbException $e) {
                return false;
            }
        }
    }
745431
public function isValidSize()
    {
        // If file was blocked via PHP for being excessive size, shortcut here
        switch ($this->tmpFile['error']) {
            case UPLOAD_ERR_INI_SIZE:
            case UPLOAD_ERR_FORM_SIZE:
                return false;
        }
        $maxSize = $this->getAllowedMaxFileSize($this->getFileExtension());
        return (!$this->tmpFile['size'] || !$maxSize || (int)$this->tmpFile['size'] < $maxSize);
    }
1274453
public function isValid()
    {
        $result = true;
        //waliduje poprawnie jeśli niewymagane, ale tylko gdy niepuste
        if (!($this->getRequired() || empty($this->getFiles()))) {
            return $result;
        }
        //iteracja po walidatorach
        foreach ($this->getValidators() as $validator) {
            if ($validator->isValid($this->getFiles())) {
                continue;
            }
            $result = false;
            //dodawanie wiadomości z walidatora
            $this->addError($validator->getMessage() ? $validator->getMessage() : $validator->getError());
        }
        //zwrot rezultatu wszystkich walidacji (iloczyn)
        return $result;
    }