Utorzenie kopii plików dla tego uploadera
@return boolean
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;
    }
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;
    }
96230
public function uploaderAction()
    {
        //parametry dla ajaxa
        $this->view->ajaxParams = [
            'module' => 'cms',
            'controller' => 'file',
            'action' => 'upload',
            'class' => $this->class,
            'object' => $this->object,
            'objectId' => $this->objectId,
            'types' => $this->types,
            'js' => $this->js,
            //znacznik czasu
            't' => $t = round(microtime(true)),
            //hash zabezpieczający oparty o znacznik czasu
            'hash' => md5($t . '+' . \Mmi\Session\Session::getId() . '+' . $this->class)
        ];
        //blad
        $this->view->error = $this->error;
        //lista obrazów
        $this->view->images = \Cms\Orm\CmsFileQuery::imagesByObject($this->object, $this->objectId)
            ->orderAscDateAdd()
            ->find();
        //lista pozostałych plików
        $this->view->files = \Cms\Orm\CmsFileQuery::notImagesByObject($this->object, $this->objectId)
            ->orderAscDateAdd()
            ->find();
    }
253370
protected function validateType () : bool
	{
		// Checks if video type is allowed
		if ($this->validateMimeType() == FALSE) return FALSE;
		// Checks if video size is valid for upload
		if ($this->validateFileSize() == FALSE) return FALSE;
		// Finally uplods the file after successful evaluation
		if ($this->uploadFile() == FALSE) return FALSE;

		return TRUE;
	}
1124552
public function delete()
    {
        //usuwanie meta
        if (!parent::delete()) {
            return false;
        }
        //plik jest ciągle potrzebny (ma linki)
        if (0 != (new CmsFileQuery)->whereName()->equals($this->name)->count()) {
            return true;
        }
        //kasowanie z systemu plików
        (new \Cms\Model\FileSystemModel($this->name))->unlink();
        //usuwanie rekordu
        return true;
    }
1168381
protected final function _broadcastDeleteAll()
    {
        //brak rozproszonego bufora, lub flush został już rozgłoszony
        if (!$this->_distributedStorage) {
            return true;
        }
        //rozgłoszenie informacji o usunięciu bufora i zapis o lokalnym czyszczeniu
        $this->_distributedStorage->save($time = time(), self::FLUSH_MESSAGE) &&
        $this->_undistributedCache->save($time, self::DEL_PREFIX . self::FLUSH_MESSAGE, 0);
    }
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;
		}
	}
1006466
protected function validateUploadFile()
    {
        $file = $this->request->file('file');

        if (empty($file)) {
            return null;
        }

        $result = $this->file_transfer->upload($file, null);

        if ($result !== true) {
            $this->setError('path', (string) $result);
            return false;
        }

        $this->setSubmitted('path', $this->file_transfer->getTransferred(true));
        return true;
    }
912031
public function stickAction()
    {
        $this->getResponse()->setTypePlain();
        //brak id
        if (!$this->id) {
            return '';
        }
        //brak pliku
        if (null === ($file = (new CmsFileQuery)->findPk($this->id)) || $this->hash != $file->name) {
            return $this->view->getTranslate()->_('Przypinanie nie powiodło się');
        }
        //przypina plik
        $file->setSticky();
        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;
    }
34573
public function isValid()
    {
        $value = $this->field->getValue();

        // no file uploaded?
        if (!$value || !isset($value['error']) || $value['error'] == UPLOAD_ERR_NO_FILE) {
            $this->setErrorMessage($this->messages['required']);
            // required ?
            return !$this->required;
        }

        // check the uploaded file
        switch ($value['error']) {
            case UPLOAD_ERR_OK:
                break;

            case UPLOAD_ERR_FORM_SIZE:
            case UPLOAD_ERR_INI_SIZE:
                $this->setErrorMessage($this->messages['file_too_big']);
                return false;

            case UPLOAD_ERR_PARTIAL:
                $this->setErrorMessage($this->messages['incomplete']);
                return false;

            case UPLOAD_ERR_NO_TMP_DIR:
            case UPLOAD_ERR_CANT_WRITE:
                $this->setErrorMessage($this->messages['cannot_write']);
                return false;

            case UPLOAD_ERR_EXTENSION:
            default:
                $this->setErrorMessage($this->messages['error']);
                return false;
        }

        /**
         * if here, the file was uploaded.
         * Validate the uploaded file against our settings (blacklist, whitelist, etc)
         */

        // retrieve the extension
        if (!$this->isExtensionAllowed($value['name'])) {
            $this->setErrorMessage(sprintf($this->messages['wrong_extension'], implode(',', $this->allowedExtensions)));
            return false;
        }

        if (!$this->isMimetypeAllowed($value['tmp_name'], $value['type'])) {
            $this->setErrorMessage($this->messages['wrong_type']);
            return false;
        }

        $size = filesize($value['tmp_name']);

        // validate the upload file size
        if ($this->maxFilesize && $size > $this->maxFilesize) {
            $this->setErrorMessage(sprintf($this->messages['file_larger_then'], $this->maxFilesize / 1024));
            return false;
        }
        if ($this->minFilesize && $size < $this->minFilesize) {
            $this->setErrorMessage(sprintf($this->messages['file_smaller_then'], $this->minFilesize / 1024));
            return false;
        }

        // if here, the extension and the mime type are validated! The file is good!
        return true;
    }
45461
public function isValid() {
		
		$file = $this -> getFile();

		$messages = [

			UPLOAD_ERR_FORM_SIZE 	=> 'File exceeds the maximum file size that was specified in the HTML form',
			UPLOAD_ERR_PARTIAL 		=> 'File was only partially uploaded',
			UPLOAD_ERR_NO_FILE		=> 'No file was uploaded',
			UPLOAD_ERR_NO_TMP_DIR	=> 'Missing a temporary folder',
			UPLOAD_ERR_CANT_WRITE	=> 'Failed to write file to disk',
			UPLOAD_ERR_EXTENSION	=> 'An extension stopped the file upload'
		];

		if(false === isset($messages[$file['error']])) {
			return true;
		}

		$this -> setMessage($messages[$file['error']]);

		return false;
	}
1094700
public function doUpload()
	{
		$mimes = $this->getOption('mimes') ? '|mimes:' . $this->getOption('mimes') : '';

		//use the multup library to perform the upload
		$result = Multup::open('file', 'max:' . $this->getOption('size_limit') * 1000 . $mimes, $this->getOption('location'),
									$this->getOption('naming') === 'random')
			->set_length($this->getOption('length'))
			->upload();

		return $result[0];
	}
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;
    }
739757
public function mime()
    {
        if (!$this->exists()) {
            return false;
        }
        if (function_exists('finfo_open')) {
            $finfo = finfo_open(FILEINFO_MIME);
            $finfo = finfo_file($finfo, $this->pwd());
            if (!$finfo) {
                return false;
            }
            list($type) = explode(';', $finfo);

            return $type;
        }
        if (function_exists('mime_content_type')) {
            return mime_content_type($this->pwd());
        }

        return false;
    }
20061
public function getRelationFiles()
    {
        $filesByObject = new \Mmi\Orm\RecordCollection;
        //wyszukiwanie wartości
        foreach ($this->getAttributeValues() as $record) {
            //pobieranie klucza atrybutu (w celu zgrupowania)
            if ($record->getJoined('cms_attribute_type')->uploader) {
                //dołączanie plików
                foreach (\Cms\Orm\CmsFileQuery::byObject($record->value, $this->_objectId)->find() as $file) {
                    $filesByObject->append($file);
                }
            }
        }
        return $filesByObject;
    }
185514
public function performUploading() {
        for ($i = 0; $i < $this->concurrentTaskNumber; ++$i) {
            if ($this->offset >= $this->fileSize) {
                break;
            }

            $sliceContent = file_get_contents($this->srcFpath, false, null, $this->offset, $this->sliceSize);
            if ($sliceContent === false) {
                $this->setError(Response::COSAPI_PARAMS_ERROR, 'read file ' . $this->srcFpath . ' error');
                return false;
            }

            $request = new HttpRequest();
            $request->timeoutMs = $this->timeoutMs;
            $request->url = $this->url;
            $request->method = 'POST';
            $request->customHeaders = array(
                        'Authorization: ' . $this->signature,
                    );
            $request->dataToPost = array(
                        'op' => 'upload_slice_data',
                        'session' => $this->session,
                        'offset' => $this->offset,
                        'filecontent' => $sliceContent,
                        'datamd5' => md5($sliceContent),
                    );
            $request->userData = array(
                        'retryCount' => 0,
                    );

            $this->libcurlWrapper->startSendingRequest($request, array($this, 'uploadCallback'));

            $this->offset += $this->sliceSize;
        }

        $this->libcurlWrapper->performSendingRequest();

        if ($this->errorCode !== Response::COSAPI_SUCCESS) {
            return false;
        }

        return true;
    }