Upload files from ckeditor
@param string $type
@return string
@throws NativeException
@throws \Ffcms\Core\Exception\SyntaxException
168503
public function actionUpload($type)
    {
        /** @var $loadFile \Symfony\Component\HttpFoundation\File\UploadedFile */
        $loadFile = App::$Request->files->get('upload');
        if ($loadFile === null || $loadFile->getError() !== 0)
            return $this->errorResponse(__('File upload failed'));

        // get file extension
        $fileExt = '.' . $loadFile->guessExtension();
        // check if this request type is allowed
        if ($this->allowedExt[$type] === null || !Any::isArray($this->allowedExt[$type]))
            throw new NativeException('Hack attempt');

        // check if this file extension is allowed to upload
        if (!Arr::in($fileExt, $this->allowedExt[$type])) {
            return $this->errorResponse(__('This file type is not allowed to upload'));
        }

        $date = Date::convertToDatetime(time(), 'd-m-Y');

        // create file hash based on name-size
        $fileNewName = App::$Security->simpleHash($loadFile->getFilename() . $loadFile->getSize()) . $fileExt;
        $savePath = Normalize::diskFullPath('/upload/' . $type . '/' . $date);
        // save file from tmp to regular
        $loadFile->move($savePath, $fileNewName);

        // generate URI of uploaded file
        $url = '/upload/' . $type . '/' . $date . '/' . $fileNewName;

        return App::$View->render('editor/load_success',
            [
                'callbackId' => (int)App::$Request->query->get('CKEditorFuncNum'),
                'url' => $url
            ],
            __DIR__);
    }
500300
public function pasteFile($type)
    {
        $this->event(YouweFileManagerEvents::BEFORE_FILE_PASTED);
        $this->resolveImage();
        $this->getDriver()->pasteFile($this->getCurrentFile(), $type);
        $this->event(YouweFileManagerEvents::AFTER_FILE_PASTED);
    }
1115120
public function upload(string $type, string $path): array
    {
        return $this->httpClient->postFile('media/upload', $path, compact('type'));
    }
1023644
public function saveImage( $type = NULL )
	{
		if( !$this->source )
			throw new RuntimeException( 'No image loaded' );
		if( !$this->target )
			throw new RuntimeException( 'No modification applied' );
		if( !$this->targetUri )
			throw new RuntimeException( 'No target image URI set' );
		$type	= $type ? $type : $this->sourceInfo[2];
		switch( $type )
		{
			case IMAGETYPE_GIF:
				return imagegif( $this->target, $this->targetUri );
			case IMAGETYPE_JPEG:
				return imagejpeg( $this->target, $this->targetUri, $this->quality );
			case IMAGETYPE_PNG:
				return imagepng( $this->target, $this->targetUri );
			default:
				throw new Exception( 'Image Type "'.$type.'" is no supported' );
		}
	}
736096
public function from($type)
    {
        switch ($type) {
            case 'ini':
                $this->data = Ini::decode($this->string);
                break;

            case 'json':
                $this->data = Json::decode($this->string);
                break;

            case 'php':
                $this->data = Php::decode($this->string);
                break;

            case 'xml':
                $this->data = Xml::decode($this->string);
                break;

            case 'yml':
            case 'yaml':
                $this->data = Yaml::decode($this->string);
                break;
            
            default:
                throw new \Exception("Format not supported: " . $type);
        }

        return $this;
    }
1117368
private function doUpload ($endpoint, $type, $body)
    {
        return json_decode(
            $this->client->send(
                new Request(
                    'POST',
                    Uri::withQueryValue(new Uri($endpoint), 'type', $type),
                    [],
                    $body
                )
            )->getBody()
        );
    }
1331143
public function setType($type)
    {
        if ($type != PdfConverter::URL && $type != PdfConverter::HTML) {
            throw new \Exception('Wrong type of file descriptor');
        }

        $this->type = $type;

        return $this;
    }
399321
public function setContentType($type)
    {
        $this->headerBag->appendPair('Content-Type', sprintf('%s;charset=%s', $type, $this->charset));
        return $this;
    }
434479
protected function uploadMedia($type, $path, array $form = [])
    {
        if (!file_exists($path) || !is_readable($path)) {
            throw new InvalidArgumentException("File does not exist, or the file is unreadable: '$path'");
        }
        $form['type'] = $type;
        return $this->upload($this->getAPIByType($type), ['media' => $path], $form);
    }
704663
protected function getUpLoadContentType($type)
    {
        switch ($type) {
            case self::UPLOAD_TYPE_IMAGE:
                return 'image/jpg';
                break;
            case self::UPLOAD_TYPE_VIDEO:
                return 'video/mp4';
                break;
            case self::UPLOAD_TYPE_VOICE:
                return 'audio/amr';
                break;
            case self::UPLOAD_TYPE_THUMB:
                return 'image/jpg';
                break;
            //@codeCoverageIgnoreStart
            default:
                break;
        }

        throw new Exception("unknown upload file type({$type})");
        //@codeCoverageIgnoreEnd
    }
1272269
public function processFile(string $type)
    {
        $this->alert(strtoupper($type) . ' PROCESS');
        foreach ($this->tables as $key => $table) {
            if ($table->relationTable === true && $type !== 'pivot') {
                continue;
            }

            if ($table->relationTable !== true && $type === 'pivot') {
                continue;
            }

            if (trim($this->option('table')) !== 'all') {
                $tableKey = $this->option('table');
                if ((int) $tableKey !== (int) $key) {
                    continue;
                }
            }

            $table->arqs = [
                $type => $this->getTemplate($type),
            ];

            foreach ($this->marks()[$type] as $mark){
                $table->arqs[$type] = str_replace('{{{' . $mark . '}}}',
                                                        trim($table->marks[$mark]),
                                                        $table->arqs[$type]);
            }

            //$this->info($table->arqs[$type]);
            $this->createFile($type, $table);
        }
    }
1023601
public function uploadMedia($type, $file)
    {
        return $this->auth(function () use ($type, $file) {
            $http = $this->http([
                'method' => 'post',
                'dataType' => 'json',
                'url' => $this->baseUrl . 'cgi-bin/media/upload?type=' . $type . '&access_token=' . $this->accessToken,
                'files' => [
                    'media' => $file,
                ],
            ]);

            return $http;
        });
    }
1009552
public function upload()
    {
        $files = request()->file('file');
        $error_bag = [];
        foreach (is_array($files) ? $files : [$files] as $file) {
            $validation_message = $this->uploadValidator($file);
            $new_filename = $this->proceedSingleUpload($file);

            if ($validation_message !== 'pass') {
                array_push($error_bag, $validation_message);
            } elseif ($new_filename == 'invalid') {
                array_push($error_bag, $response);
            }
        }

        if (is_array($files)) {
            $response = count($error_bag) > 0 ? $error_bag : parent::$success_response;
        } else { // upload via ckeditor 'Upload' tab
            $response = $this->useFile($new_filename);
        }

        return $response;
    }
658126
protected function setType($type)
    {
        if ($type == '*/*' || $type == 'application/octet-stream')
        {
            $type = \Module\HttpFoundation\getMimeTypeOfFile($this->getTmpName(), false);
            if ( empty($type) )
                if ( null !== $solved = \Module\HttpFoundation\getMimeTypeOfFile($this->getClientFilename()) )
                    $type = $solved;
                else
                    $type = 'application/octet-stream';
        }

        $this->type = (string) $type;
        return $this;
    }
131809
public function upload(String $localPath, String $remotePath, String $type = 'ascii') : Bool
    {
        if( ftp_put($this->connect, $remotePath, $localPath, Helper::toConstant($type, 'FTP_')) )
        {
            return true;
        }
        else
        {
            throw new FileRemoteUploadException($localPath);
        }
    }
1364765
public function addType($type)
    {
        if ($type instanceof Type) {
            $type = $type->getName();
        }

        if (!\is_string($type)) {
            throw new InvalidException('Invalid type type');
        }

        $this->_types[] = $type;

        return $this;
    }
550096
private function normalizeType(string $type) : ?TypeDoc
    {
        if (array_key_exists($type, self::MANAGED_TYPE_CLASS_LIST)) {
            $class = self::MANAGED_TYPE_CLASS_LIST[$type];

            return new $class();
        }

        return null;
    }