Sestavení výchozí šablony uploaderu.

@return Html
544177
public function buildDefaultTemplate() {
		$customContainer = Html::el("div");
		
		$this->elements["input"]->setAttribute("style", "display: none");
		$id = $this->elements["input"]->getAttribute("id");
		$button = Html::el("button type='button' class='btn btn-primary mb-2'");
		$button->setAttribute("onclick", "document.getElementById('$id').click(); return false;");
		$button->setText("Nahrát soubor");
		
		$customContainer->addHtml($this->elements["input"]);
		$customContainer->addHtml($button);
		
		$globalProgress = $this->elements["globalProgress"]
			->setAttribute("class", "progress-bar")
			->setAttribute("style", "height: 20px");
		$progressContainer = Html::el("div class='progress mb-2'");
		$progressContainer->addHtml($globalProgress);
		$customContainer->addHtml($progressContainer);
		
		$container = $this->elements["container"];
		$container->setName("table");
		$container->setAttribute("class", "table");
		
		$thead = Html::el("thead class='thead-inverse'");
		$tr = Html::el("tr");
		$preview = Html::el("th style='width: 15%;'");
		$tr->addHtml($preview);
		$filename = Html::el("th")->setText("Soubor");
		$tr->addHtml($filename);
		$status = Html::el("th style='width: 20%'")->setText("Stav");
		$tr->addHtml($status);
		$actions = Html::el("th style='width: 50px'");
		$tr->addHtml($actions);
		$thead->addHtml($tr);
		
		$container->addHtml($thead);
		$customContainer->addHtml($container);
		
		return $customContainer;
	}
10835
public function build(): Html
	{
		$wrapper = Html::el();
		foreach ($this->tags as $property => $content) {
			$wrapper->addHtml(Html::el('meta')->addAttributes([
				'property' => $property,
				'content' => $content,
			]));
		}

		return $wrapper;
	}
510550
public function buildDeleterBehaviour()
    {
        return '$(document).ready(function() {
                    $("#' . $this->buildDeleteButtonId() . '").click(function() {
                        var $form = $(this).parents("form"),
                            $fileHandling = $form.find("[name=\'' . $this->getName() . '\']");
                        if(!$fileHandling.length) {
                            $fileHandling = $("<input>", { name: "' . $this->getName() . '", type: "hidden" });
                            $form.prepend($fileHandling); 
                        }
                        $fileHandling.val("{\\"action\\":\\"delete\\"}");
                        $("#' . $this->buildWidgetContainerId() . '").empty();
                        ' . $this->buildUploaderBehaviour(true) . '
                    });
                });';
    }
688349
public function uploadAction()
    {
        $request    = $this->getRequest();
        $locator    = $this->getServiceLocator();
        $model      = $locator->get( 'Grid\Paragraph\Model\Snippet\Model' );
        $snippet    = $model->create();
        $form       = $locator->get( 'Form' )
                              ->create( 'Grid\Paragraph\Snippet\Upload' );

        /* @var $form \Zend\Form\Form */
        $form->setHydrator( $model->getMapper() )
             ->bind( $snippet );

        if ( $request->isPost() )
        {
            $form->setData( ArrayUtils::merge(
                $request->getPost()->toArray(),
                $request->getFiles()->toArray()
            ) );

            if ( $form->isValid() &&
                 ( $form->getData()
                        ->getOption( 'overwrite' ) ||
                   $model->isNameAvailable( $snippet->name ) ) &&
                 $snippet->save() )
            {
                $this->messenger()
                     ->add( 'paragraph.form.snippet.success',
                            'paragraph', Message::LEVEL_INFO );

                return $this->redirect()
                            ->toRoute( 'Grid\Paragraph\Snippet\List', array(
                                'locale' => (string) $this->locale(),
                            ) );
            }
            else
            {
                $this->messenger()
                     ->add( 'paragraph.form.snippet.failed',
                            'paragraph', Message::LEVEL_ERROR );
            }
        }

        $form->setCancel(
            $this->url()
                 ->fromRoute( 'Grid\Paragraph\Snippet\List', array(
                        'locale' => (string) $this->locale(),
                    ) )
        );

        return array(
            'form'  => $form,
        );
    }
901075
public function uploadAction()
    {
        $authenticationService = $this->getServiceLocator()->get('zfcuser_auth_service');
        if (!$authenticationService->hasIdentity()) {
            return $this->redirect()->toRoute('zfcuser');
        }

        $user = $this->getUser();
        if (!$user) {
            return $this->notFoundAction();
        }
        $options = $this->getOptions();
        $form = $this->getServiceLocator()->get('HtProfileImage\ProfileImageForm');
        /** @var \Zend\Http\Request $request */
        $request = $this->getRequest();
        $imageUploaded = false;
        if ($request->isPost()) {
            $negotiator   = new FormatNegotiator();
            $format = $negotiator->getBest(
                $request->getHeader('Accept')->getFieldValue(),
                ['application/json', 'text/html']
            );
            if ($this->profileImageService->storeImage($user, $request->getFiles()->toArray())) {
                if ($format->getValue() === 'application/json') {
                    return new Model\JsonModel([
                        'uploaded' => true
                    ]);
                } elseif ($options->getPostUploadRoute()) {
                        return call_user_func_array([$this->redirect(), 'toRoute'], (array) $options->getPostUploadRoute());
                }
                $imageUploaded = true;
            } else {
                $response = $this->getResponse();
                /** @var \Zend\Http\Response $response */
                $response->setStatusCode(400);
                if ($format->getValue() === 'application/json') {
                    return new Model\JsonModel([
                        'error' => true,
                        'messages' => $form->getMessages()
                    ]);
                }

            }
        }

        return new Model\ViewModel([
            'form' => $form,
            'imageUploaded' => $imageUploaded,
            'user' => $user
        ]);
    }
1296282
function toHTML()
    {

        // all file upload controls must have the "upload" rule set or we trigger an error
        if (!isset($this->rules['upload'])) _zebra_form_show_error('The control named <strong>"' . $this->attributes['name'] . '"</strong> in form <strong>"' . $this->form_properties['name'] . '"</strong> must have the <em>"upload"</em> rule set', E_USER_ERROR);

        // if the "image" rule is set
        if (isset($this->rules['image']))

            // these are the allowed file extensions
            $allowed_file_types = array('jpe', 'jpg', 'jpeg', 'png', 'gif');

        // if the "filetype" rule is set
        elseif (isset($this->rules['filetype']))

            // get the array of allowed file extensions
            $allowed_file_types = array_map('trim', explode(',', $this->rules['filetype'][0]));

        // if file selection should be restricted to certain file types
        if (isset($allowed_file_types)) {

            $mimes = array();

            // iterate through allowed extensions
            foreach ($allowed_file_types as $extension)

                // get the mime type for each extension
                if (isset($this->form_properties['mimes'][$extension]))

                    $mimes = array_merge($mimes, (array)$this->form_properties['mimes'][$extension]);

            // set the "accept" attribute
            // see http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#file-upload-state-%28type=file%29
            // at the time of writing, on December 30, 2012, this was only working on Chrome 23 and IE 10
            $this->set_attributes(array('accept' => '.' . implode(',.', $allowed_file_types) . ',' . implode(',', $mimes)));

        }

        // show the file upload control
        $output = '<input ' . $this->_render_attributes() . ($this->form_properties['doctype'] == 'xhtml' ? '/' : '') . '>';

        // return the generated output
        return $output;

    }
507630
protected function createResumeUri()
    {
        $headers = $this->headers + [
            'X-Upload-Content-Type' => $this->contentType,
            'X-Upload-Content-Length' => $this->data->getSize(),
            'Content-Type' => 'application/json'
        ];

        $body = $this->jsonEncode($this->metadata);

        $request = new Request(
            'POST',
            $this->uri,
            $headers,
            $body
        );

        $response = $this->requestWrapper->send($request, $this->requestOptions);

        return $this->resumeUri = $response->getHeaderLine('Location');
    }
877040
public function upload() : string
    {
        if (!$this->_validateUpload()) {
            return '';
        }

        $result = $this->_uploadFile();

        if ('' === $result) {
            $this->flash->error('Unable to upload file to the specified directory.');
        }

        return $result;
    }
362004
public function pluploadAction()
    {
        set_time_limit(5 * 60);
        //obiekt handlera plupload
        $pluploadHandler = new Model\PluploadHandler();
        //jeśli wystąpił błąd
        if (!$pluploadHandler->handle()) {
            return $this->_jsonError($pluploadHandler->getErrorCode(), $pluploadHandler->getErrorMessage());
        }
        //jeśli wykonać operację po przesłaniu całego pliku i zapisaniu rekordu
        if ($this->getPost()->afterUpload && null !== $record = $pluploadHandler->getSavedCmsFileRecord()) {
            $this->_operationAfter($this->getPost()->afterUpload, $record);
        }
        return json_encode(['result' => 'OK', 'cmsFileId' => $pluploadHandler->getSavedCmsFileId()]);
    }
275589
public function newUpload()
    {
        if (null === $this->getFile()) {
            return null;
        }

        $this->moveFile();

        return $this->getUploadRootDir() . $this->path;
    }
401193
public function getFileUpload()
    {
        $propertyName = $this->getFileUploadPropertyName(__FUNCTION__);

        if (isset($this->fileUploads[$propertyName])) {
            return $this->fileUploads[$propertyName];
        }
    }
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();
    }
19640
public function uploadToContentService() {
		/** @var \File $file */
		$file = $this->owner;
		$writer = $this->writer();
		if (!$writer) {
			return;
		}
		$path = $file->getFullPath();
		if (strlen($path) && is_file($path) && file_exists($path)) {

			$mtime = @filemtime($path);
            $name = trim($file->getFilename(), '/');
		if (!$mtime) {
                    $mtime = '0';
                }

			//Insert the file modified time to make file unique-ish
			if ($lastPos = strrpos($name, '/')) {
				// Add in at as last folder name
				$name = substr($name, 0, $lastPos) . '/' . $mtime . substr($name, $lastPos);
			} else {
				//No folder found create one for the mtime
				$name = $mtime . '/' . $name;
			}

			$fileKeyLength = strlen($name);
			if ($fileKeyLength > CDNFile::MAX_FILE_PATH_LENGTH) {
				$lastPos = strrpos($name, '/');
				$ext = '';
				$filename = substr($name, $lastPos + 1);
				// Try and find a file extension
				if (strrpos($name, '.') !== false) {
					// Store and trim extension for later replacement
					$ext = substr($name, strrpos($name, '.'));
					$filename = substr($filename, 0, strrpos($filename, '.'));
				}
				// add 1 here so we can add in a ~ to indictate truncation
				$truncateLength = ($fileKeyLength + strlen($ext) + 1) - CDNFile::MAX_FILE_PATH_LENGTH;
				if (strlen($filename) <= $truncateLength) {
					// Folder length exceeds CDNFile::MAX_FILE_PATH_LENGTH. MD5 file to prevent file loss log error
					SS_Log::log("CDNFile: Total file length (folders + name) exceeds " . CDNFile::MAX_FILE_PATH_LENGTH . " characters and can't be "
							. "trimmed. File key has been MD5 encoded. File key: " . md5($name) . $ext . " Filename: "
							. "$name", SS_Log::ERR);
					$name = md5($name) . $ext;
				} else {
					// Recombine folder and file name while truncating the filename and appending a ~ then extension
					$name = substr($name, 0, $lastPos) . '/' . substr($filename, 0, (0 - $truncateLength)) . '~' . $ext;
				}
			}


			$writer->write(fopen($path, 'r'), $name);

			// writer should now have an id
			$file->CDNFile = $writer->getContentId();
            $file->FileSize = @filesize($path);

            // check whether it's an image, and handle its dimensions
            if ($file instanceof CdnImage) {
                $file->storeDimensions();
            }

			$file->write();

            // confirm the remote upload is there, and delete the local file
            // Oct 2016 - UNLESS the versioned files extension is on, we have to treat it slightly different
            $this->deleteLocalIfExistsOnContentService();
		}
	}
837340
public function upload()
    {
        $params = $this->getUploadParams();

        if ($params) {
            $class = $this->class;
            $uri = $class::getUri();
            $document = static::post($this->client, $uri, $params);

            /** @var Model $instance */
            $instance = new $this->class($this->client, $document);
            $instance->exists = true;
            $instance->cacheFields($document);
            return $instance;
        }

        return null;
    }
1346155
public static function createGlobal()
    {
        $uri = new Uri(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '');
        $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
        $request = new self(
            $uri,
            $method,
            $_GET,
            $_POST,
            $_COOKIE,
            UploadedFile::convert($_FILES),
            $_SERVER
        );
        foreach ($_SERVER as $name => $value) {
            if (substr_compare($name, 'HTTP_', 0, 5) === 0) {
                $request->setHeader(str_replace('_', '-', substr($name, 5)), $value);
            }
        }
        return $request;
    }
961782
public function generate()
    {
        $return = '';

        if (empty($this->thumbnailSize)) {
            $this->thumbnailSize = [
                Config::get('imageWidth'),
                Config::get('imageHeight'),
                'box',
            ];
        }

        $file = FilesModel::findByPk($this->varValue);
        if (null === $file && null !== $this->fallbackImage) {
            $file = FilesModel::findByPk($this->fallbackImage);
        }
        if (null !== $file) {
            $altTag = $file->name;
            $size   = deserialize($this->thumbnailSize);
            $image  = Image::create($file->path, $size)->executeResize();

            $return .= sprintf(
                '<img src="%s" width="%s" height="%s" alt="%s" class="uploaded-image">',
                $image->getResizedPath(),
                $image->getTargetWidth(),
                $image->getTargetHeight(),
                $altTag
            );
        }

        if ($this->addMetaWizard) {
//@todo add meta wizard here
        }

        $return .= parent::generate();

        if ($this->enableReset) {
            $return .= sprintf(
                '<input type="checkbox" name="%s" class="checkbox" value=""><label>%s</label> ',
                $this->strName.'_reset',
                'Reset'
            );
        }

        return $return;
    }
910706
public function upload()
        {
            $files = $this->getFiles();
            $response = [];

            foreach($files as $file){

                if(!$file instanceof Upload)
                {
                    $file = new FileUpload($file);
                }

                $response[] = $file->upload();
            }

            return $response;
        }