Uploader::process

@param string|null $field Field offset server uploaded files

@return bool Returns TRUE on success or FALSE on failure.
552999
public function process($field = null)
    {
        $uploadFiles = input()->files($field);

        if ( ! is_array($uploadFiles)) {
            $uploadFiles = [$uploadFiles];
        }

        if (count($uploadFiles)) {
            foreach ($uploadFiles as $file) {
                if ($file instanceof UploadFile) {
                    if (defined('PATH_STORAGE')) {
                        if ($this->path === PATH_STORAGE) {
                            if (strpos($file->getClientMediaType(), 'image') !== false) {
                                $this->path = $this->path . 'images' . DIRECTORY_SEPARATOR;
                            } else {
                                $this->path = $this->path . 'files' . DIRECTORY_SEPARATOR;
                            }
                        }
                    }

                    $targetPath = $this->path;

                    if (empty($this->targetFilename)) {
                        $this->setTargetFilename($file->getClientFilename());
                    }

                    $filename = $this->targetFilename;

                    if ($this->validate($file)) {
                        if ( ! is_file($filePath = $targetPath . $filename . '.' . $file->getExtension())) {
                            $this->move($file, $filePath);
                        } elseif ( ! is_file($filePath = $targetPath . $filename . '-1' . '.' . $file->getExtension())) {
                            $this->move($file, $filePath);
                        } else {
                            $existingFiles = glob($targetPath . $filename . '*.' . $file->getExtension());
                            if (count($existingFiles)) {
                                $increment = count($existingFiles) - 1;
                            }

                            foreach (range($increment + 1, $increment + 3, 1) as $increment) {
                                if ($increment > $this->maxIncrementFilename) {
                                    $this->errors[] = language()->getLine(
                                        'UPLOADER_E_MAXIMUM_INCREMENT_FILENAME',
                                        [$file->getClientFilename()]
                                    );
                                }

                                if ( ! is_file($filePath = $targetPath . $filename . '-' . $increment . '.' . $file->getExtension())) {
                                    $this->move($file, $filePath);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            if (count($this->errors) == 0) {
                return true;
            }
        }

        return false;
    }
862352
public function run( $field, $value, $message = null ) {

        $this->field   = $field;
        $this->message = $message;

        if ( ! $this->fieldKey || ! $this->fields ) {
            return false;
        }

        if ( $this->fields[ $this->fieldKey ] == $value ) {
            return true;
        }

        return false;
    }
1124936
public function addFieldCache($field)
    {
        if ( !$cache = $this->getMongator()->getFieldsCache() ) {
            return null;
        }

        $field = preg_replace('/\.\d+/', '', $field);

        foreach ($this->getQueryHashes() as $hash) {
            $value = $cache->get($hash);
            if (!$value) $value = array();

            if ( !isset($value['fields'][$field]) || $value['fields'][$field] != 1 ) {
                $value['fields'][$field] = 1;
                $cache->set($hash, $value);
            }
        }
    }
294708
public function fieldPosition($field)
    {
        if (is_string($field)) {
            $field = $this->fieldByName($field);
        }
        if (!$field) {
            return false;
        }

        $i = 0;
        foreach ($this->children as $child) {
            /** @var FormField $child */
            if ($child->getName() == $field->getName()) {
                return $i;
            }
            $i++;
        }

        return false;
    }
163812
public function value($field)
    {
        if (is_array($field)) {
            $values = array();
            foreach ($field as $key => $value) {
                $values[$key] = $this->value($value);
            }

            return $values;
        }

        return ($this->submitted && isset($this->values[$field])) ? $this->values[$field] : null;
    }
647764
public function addUploadedFile(UploadedFileInterface $upload, string $field = null, array $crop = null): string
    {
        $tmp_dir = $this->getTmpDir();
        $tmp_name = Utils::generateRandomString(12);
        $name = $upload->getClientFilename();

        // Prepare upload data for later save
        $data = [
            'name' => $name,
            'type' => $upload->getClientMediaType(),
            'size' => $upload->getSize(),
            'tmp_name' => $tmp_name
        ];

        Folder::create($tmp_dir);
        $upload->moveTo("{$tmp_dir}/{$tmp_name}");

        $this->addFileInternal($field, $name, $data, $crop);

        return $name;
    }
1255145
public function fileValidator(string $field, $suffixes = null): bool
    {
        if (!$file = $this->uploadedFiles[$field] ?? null) {
            return false;
        }

        if (!isset($file['error']) || ($file['error'] !== \UPLOAD_ERR_OK)) {
            return false;
        }

        if (!$suffixes) {
            return true;
        }

        if (!$suffix = \trim(\strrchr($file['name'], '.'), '.')) {
            return false;
        }

        $suffixes = \is_string($suffixes) ? Filters::explode($suffixes) : (array)$suffixes;

        return \in_array(\strtolower($suffix), $suffixes, true);
    }
611596
function processFile($token, $file)
	{
		// Why not in one condition?
		// @see http://forum.nettephp.com/cs/viewtopic.php?pid=29556#p29556
		if (!$file instanceof FileUpload) {
			return false;
		}

		/* @var $validateCallback Callback */
		$validateCallback = MultipleFileUpload::$validateFileCallback;

		/* @var $isValid bool */
		$isValid = $validateCallback->invoke($file);

		if ($isValid) {
			MultipleFileUpload::getQueuesModel()
				->getQueue($token)
				->addFile($file);
		}
		return $isValid;
	}
778085
protected function _process()
    {
        $name = $this->config('field');
        $this->value = $this->_registry->data($name);
        $this->_processed = true;
    }
1339588
public function run( $field, $value , $message = null)
    {
        $this->field = $field;
        $this->message = $message;

        if(preg_match($this->pattern, $value)){
            return true;
        }

        return false;
    }
140108
public function changed($field = null)
    {
        return (null === $field)
            ? $this->_changed
            : Arr::get($this->_changed, $field);
    }
825092
protected function nullableChanged($field = null)
    {
        if (!$field) {
            $function = debug_backtrace()[1]['function'];
            $field    = lcfirst(substr($function, 3));
        }

        $this->nullableChanged[$field] = true;
    }
589401
private function processInput($field)
    {
        $output = '';
        if ($field['div'] == TRUE) $output .= $this->div('open', $field['divId'], $field['divClass'], $field['divAttributes']);
        switch (strtolower($field['type'])) {
            case 'a':
                if ($field['name'] != '' || $field['value'] != '') {
                    $url = sprintf('%s?%s', $field['name'], $field['value']);
                }
                $output .= $this->a('full', $field['id'], $field['class'], $field['attributes'], $url, $field['labelText']);
                break;
            case 'br':
                $output .= $this->br('full', $field['id'], $field['class'], $field['attributes']);
                break;
            case 'divopen':
                $output .= $this->div('open', $field['id'], $field['class'], $field['attributes']);
                break;
            case 'divclose':
                $output .= $this->div('close');
                break;
            case 'span':
                $output .= $this->span('full', $field['id'], $field['class'], $field['attributes'], $field['value']);
                break;
            case 'checkbox':
            case 'radio':
                $output .= $this->input('full', $field['id'], $field['class'], $field['attributes'], $field['type'], $field['name'], $field['value']);
                $output .= $this->label('full', $field['labelId'], $field['labelClass'], $field['labelAttributes'], $field['id'], $field['labelText']);
                break;
            case 'select':
                if ($field['labelText'] != '') {
                    $output .= $this->label('full', $field['labelId'], $field['labelClass'], $field['labelAttributes'], $field['id'], $field['labelText']);
                }
                $output .= $this->select('full', $field['id'], $field['class'], $field['attributes'], $field['name'], $field['value']);
                break;
            case 'textarea':
                if ($field['labelText'] != '') {
                    $output .= $this->label('full', $field['labelId'], $field['labelClass'], $field['labelAttributes'], $field['id'], $field['labelText']);
                    $output .= $this->br('full');
                }
                $output .= $this->textarea('full', $field['id'], $field['class'], $field['attributes'], $field['name'], 0, 0, $field['value']);
                break;
            default:
                if ($field['labelText'] != '') {
                    $output .= $this->label('full', $field['labelId'], $field['labelClass'], $field['labelAttributes'], $field['id'], $field['labelText']);
                }
                if ($field['placeholder'] != '') $this->fixInputAttributes($field);
                $output .= $this->input('full', $field['id'], $field['class'], $field['attributes'], $field['type'], $field['name'], $field['value']);
        }
        if ($field['div'] == TRUE) $output .= $this->div('close');
        return $output;
    }
903463
public function processRequest()
    {
        foreach($this->xPluginManager->getRequestPlugins() as $xPlugin)
        {
            if($xPlugin->getName() != Jaxon::FILE_UPLOAD && $xPlugin->canProcessRequest())
            {
                $xUploadPlugin = $this->xPluginManager->getRequestPlugin(Jaxon::FILE_UPLOAD);
                // Process uploaded files
                if($xUploadPlugin != null)
                {
                    $xUploadPlugin->processRequest();
                }
                // Process the request
                return $xPlugin->processRequest();
            }
        }
        // Todo: throw an exception
        return false;
    }
802303
protected function validateFieldAddress($field)
    {
        if ($this->isExcluded($field) || $this->isError('country')) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $format = $this->getCountryFormatAddress();

        if (empty($format[$field]['required'])) {
            return null;
        }

        if (!isset($value) || $value === '' || mb_strlen($value) > 255) {
            $this->setErrorLengthRange($field, $format[$field]['name'], 1, 255);
            return false;
        }

        return true;
    }
845642
public function upload($_field, $_base64 = false) {

        if ( !$this->checkUploadDir() ) {
            $this->errNum = 6;
            return false;
        }

		if ( $_base64 ) {
			$_data = $_POST[$_field];
			return $this->makeBase64Image( $_data );
		}

		$_localFile = $_FILES[$_field]['name'];
        if ( !$_localFile ) {
            $this->errNum = 10;
            return false;
        }
		$_tempFile = $_FILES[$_field]['tmp_name'];//原来是这样
        //$_tempFile = str_replace('\\\\', '\\', $_FILES[$_field]['tmp_name']);//MAGIC_QUOTES_GPC=OFF时，做了这样处理：$_FILES = daddslashes($_FILES);图片上传后tmp_name值变成 X:\\Temp\\php668E.tmp，结果move_uploaded_file() 函数判断为不合法的文件而返回FALSE。
		$_error_no = $_FILES[$_field]['error'];
        $this->fileInfo['file_type'] = $_FILES[$_field]['type'];
        $this->fileInfo['local_name'] = $_localFile;
        $this->fileInfo['file_size'] = $_FILES[$_field]['size'];

        $this->errNum = $_error_no;
        if ( $this->errNum == 0 ) {
            $this->checkFileType($_localFile);
            if ( $this->errNum == 0 ) {
                $this->checkFileSize($_tempFile);
                if ( $this->errNum == 0 ) {
                    if ( is_uploaded_file($_tempFile) ) {
                        $_new_filename = $this->getFileName($_localFile);
                        $this->fileInfo['file_path'] = $this->config['upload_dir'].DIRECTORY_SEPARATOR.$_new_filename;
                        if ( move_uploaded_file($_tempFile, $this->fileInfo['file_path']) ) {

                            $_filename = $_new_filename;
                            $this->fileInfo['file_name'] = $_filename;
                            $pathinfo = pathinfo($this->fileInfo['file_path']);
                            $this->fileInfo['file_ext'] =  $pathinfo['extension'];
                            $this->fileInfo['raw_name'] = $pathinfo['filename'];

                            return $this->fileInfo;

                        } else {
                            $this->errNum = 7;
                        }
                    }
                }
            }
        }

		return false;

	}
605346
public function delField(string $field) : bool
        {
                return $this->_redis->hdel($this->_key, $field) > 0 ? true : false;
        }