private function processUpload(DirectoryInterface $directory, $filename, array $fileToProcess)
    {
        $this->app['upload.namespace'] = $directory->getMountPoint();
        $handler = $this->app['upload'];
        $handler->setPrefix($directory->getPath() . '/');
        try {
            $result = $handler->process($fileToProcess);
        } catch (IOException $e) {
            $message = Trans::__('page.file-management.message.upload-not-writable', ['%TARGET%' => $directory->getPath()]);
            $this->flashes()->error($message);

            return;
        }

        if ($result->isValid()) {
            $this->flashes()->info(
                Trans::__('page.file-management.message.upload-success', ['%file%' => $filename])
            );

            // Add the file to our stack.
            try {
                $this->app['stack']->add($directory->getFile($filename));
            } catch (FileNotStackableException $e) {
                // Doesn't matter. Just trying to help the user.
            }

            $result->confirm();
        } else {
            foreach ($result->getMessages() as $message) {
                $this->flashes()->error((string) $message);
            }
        }
    }
private function processUpload(DirectoryInterface $directory, $filename, array $fileToProcess)
    {
        $this->app['upload.namespace'] = $directory->getMountPoint();
        $handler = $this->app['upload'];
        $handler->setPrefix($directory->getPath() . '/');
        try {
            $result = $handler->process($fileToProcess);
        } catch (IOException $e) {
            $message = Trans::__('page.file-management.message.upload-not-writable', ['%TARGET%' => $directory->getPath()]);
            $this->flashes()->error($message);

            return;
        }

        if ($result->isValid()) {
            $this->flashes()->info(
                Trans::__('page.file-management.message.upload-success', ['%file%' => $filename])
            );

            // Add the file to our stack.
            try {
                $this->app['stack']->add($directory->getFile($filename));
            } catch (FileNotStackableException $e) {
                // Doesn't matter. Just trying to help the user.
            }

            $result->confirm();
        } else {
            foreach ($result->getMessages() as $message) {
                $this->flashes()->error((string) $message);
            }
        }
    }
private function processUpload ( DirectoryInterface $ directory , $ filename , array $ fileToProcess ) { $ this -> app [ 'upload.namespace' ] = $ directory -> getMountPoint ( ) ; $ handler = $ this -> app [ 'upload' ] ; $ handler -> setPrefix ( $ directory -> getPath ( ) . '/' ) ; try { $ result = $ handler -> process ( $ fileToProcess ) ; } catch ( IOException $ e ) { $ message = Trans :: __ ( 'page.file-management.message.upload-not-writable' , [ '%TARGET%' => $ directory -> getPath ( ) ] ) ; $ this -> flashes ( ) -> error ( $ message ) ; return ; } if ( $ result -> isValid ( ) ) { $ this -> flashes ( ) -> info ( Trans :: __ ( 'page.file-management.message.upload-success' , [ '%file%' => $ filename ] ) ) ; // Add the file to our stack. try { $ this -> app [ 'stack' ] -> add ( $ directory -> getFile ( $ filename ) ) ; } catch ( FileNotStackableException $ e ) { // Doesn't matter. Just trying to help the user. } $ result -> confirm ( ) ; } else { foreach ( $ result -> getMessages ( ) as $ message ) { $ this -> flashes ( ) -> error ( ( string ) $ message ) ; } } }
Process an individual file upload.

@param DirectoryInterface $directory
@param string             $filename
@param array              $fileToProcess
Process an individual file upload .