Add File.

@return \Zend\Stdlib\ResponseInterface
332842
public function addAction()
    {
        $parent = $this->params()->fromRoute('parent');
        if (! is_numeric($parent)) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('The article location was not specified.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }
        try {
            $articleId = $this->getArticleService()->makeArticle($parent);
        } catch (RuntimeException $e) {
            $this->flashMessenger()->addMessage($e->getMessage());
            return $this->redirect()
                ->toRoute('sc-admin/content-manager')
                ->setStatusCode(303);
        }

        return $this->redirect()->toRoute(
            'sc-admin/article/edit',
            ['id' => $articleId]
        );
    }
575574
protected function sftpUploadFile(): FunctionsInterface
    {
        /* the directory structure on remote host must exist to SFTP */
        if ($this->get('_localFileSize') > 0) {
            $this->get('_sftp')->uploadFile($this->get('_remoteFilePath'), $this->get('_localCacheFilePath'));
        }

        return $this;
    }
1286406
public function pluginFile()
    {
        if (!empty($this->request->query['file'])) {
            $path = $this->request->query['file'];
            $path = str_replace_once('#', '', $path);
            $file = str_replace('//', '/', ROOT . "/plugins/{$path}");
            if ((strpos($file, 'webroot') !== false || strpos($file, '.tmb') !== false) && file_exists($file)) {
                $this->response->file($file);

                return $this->response;
            }
        }
        die;
    }
550725
public function uploadAction ()
    { 
        $handle = $this->getRequest()->files->get('file');
        
        if ($handle && $handle->getError()){
            return new JsonResponse(array(
                'success' => false,
                'err_msg' => $this->container->get('translator')
                    ->trans('file_upload_http_error', array(), 'ThraceMediaBundle')
            ));
        }
        
        $fileManager = $this->container->get('thrace_media.filemanager');
        $extension = $handle->getClientOriginalExtension();
        $name = uniqid() . '.' . $extension;
        
        if(!$extension){
            return new JsonResponse(array(
                'success' => false,
                'err_msg' => sprintf('Unknown Mime Type: "%s"', $handle->getMimeType())
            ));
        }

        $validate = $this->validateFile($handle);

        if ($validate !== true) {
            return new JsonResponse(array(
                'success' => false,
                'err_msg' => $validate
            ));
        }
        
        $content = file_get_contents($handle->getRealPath());
        $fileManager->saveToTemporaryDirectory($name, $content);
        $hash = $fileManager->checksumTemporaryFileByName($name);

        return new JsonResponse(array(
            'success' => true,
            'name'    => $name,
            'hash'    => $hash,
        ));
        
    }
986692
private function addFileSystemNode()
    {
        $builder = new TreeBuilder();
        $node = $builder->root('file_system');

        $node
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('directory')->defaultValue('%sulu.cache_dir%/preview')->end()
                ->scalarNode('extension')->defaultNull()->end()
                ->integerNode('umask')->defaultValue(0002)->end()
            ->end();

        return $node;
    }
528748
public function create() 
    {
        try {            
            $fileData['alias'] = Input::get('filename') ? Input::get('filename') : date('m.d.Y - G:i:s');
            $fileData['type'] = 'folder';
            if(Input::get('pid') > 0) {
                $fileData['parent_id'] = Input::get('pid');
            }
            
            $this->file->create($fileData);

            return response()->json([
                'status' => 'success'
            ]);
        }
        
        catch (Exception $e) {
            return $this->handleError($e);
        }
    }
1139369
public function add()
    {
        $position = $this->BannersPositions->newEntity();

        if ($this->request->is('post')) {
            $position = $this->BannersPositions->patchEntity($position, $this->request->getData());

            if ($this->BannersPositions->save($position)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('position'));
    }
377867
public function upload()
	{
		//create the response object
		$response = new UploadResponseClass();

		//do upload in try...catch block to enable catching errors
		try{

			//upload file	
		 	if (move_uploaded_file($_FILES[$this->file_name]["tmp_name"], $this->target_file))
		 	{
		 		//set success parameters
		 		$response->success = true;
		 		$response->upload_path_full = $this->target_file;
		 		$response->upload_path_relative = $this->upload_path_relative;
		 		$response->file_name = $_FILES[$this->file_name]["name"];
		 		$response->file_size = $this->file_size;

		 		return $response;

	    	} 

	    	else 
	    	{
	        	//return error message
	        	$response->error = true;

	        	return $response;
	    	
	    	}

	    }
	    catch(UploadException $uploadExceptionObject){

	    	//display error message
	    	$uploadExceptionObject->errorShow();
	    	

	    }

	}
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
        ]);
    }
371355
public function upload()
	{
		$response = array('uploaded' => false);

		foreach ((array)$_FILES as $file) {
			$targetFolder = isset($_POST['folder']) ? $_POST['folder'] : '/';
			$response = array_merge($response, $this->uploadFile($file, $targetFolder . '/'));
		}
        $this->returnJson($response);
	}
428984
public function build(): SetFileInputFilesRequest
	{
		$instance = new SetFileInputFilesRequest();
		if ($this->files === null) {
			throw new BuilderException('Property [files] is required.');
		}
		$instance->files = $this->files;
		$instance->nodeId = $this->nodeId;
		$instance->backendNodeId = $this->backendNodeId;
		$instance->objectId = $this->objectId;
		return $instance;
	}
1319221
public function add($file)
    {
        if ($file instanceof SplFileInfo) {
            throw InvalidArgumentException::create(
                sprintf(
                    '%1$s/FileBag|%1$s/File[]|%1$s/File',
                    __NAMESPACE__
                ),
                $file
            );
        }

        return parent::add($file);
    }
696123
protected function getFileRepository()
    {
        if (null === $this->fileRepository) {
            $this->fileRepository = new FileRepository($this->getConnection());
        }

        return $this->fileRepository;
    }
988401
public function handleFilesFromRequest()
    {
        $request = $this->requestStack->getCurrentRequest();
        if(!empty($request)) {
            $this->handleFiles($request);
        }
        return $this;
    }
1193908
public function addAction()
    {
        $isPosted = $this->request->getPost('doCreate');
        
        if (!$isPosted) {
            $this->response->redirect($this->request->getPost('redirect'));
        }

        $comment = [
            'content'   => $this->request->getPost('content'),
            'name'      => $this->request->getPost('name'),
            'web'       => $this->request->getPost('web'),
            'mail'      => $this->request->getPost('mail'),
            'timestamp' => time(),
            'ip'        => $this->request->getServer('REMOTE_ADDR'),
        ];

        $comments = new \Phpmvc\Comment\CommentsInSession();
        $comments->setDI($this->di);

        $comments->add($comment);

        $this->response->redirect($this->request->getPost('redirect'));
    }
680705
private function addPhpFileNode()
    {
        $builder = new TreeBuilder('php_file');
        $node    = $this->getRootNode($builder, 'php_file');

        $node
            ->addDefaultsIfNotSet()
            ->children()
                ->scalarNode('directory')->defaultValue('%kernel.cache_dir%/doctrine/cache/phpfile')->end()
                ->scalarNode('extension')->defaultNull()->end()
                ->integerNode('umask')->defaultValue(0002)->end()
            ->end()
        ;

        return $node;
    }
100803
public function addFile(Request $request)
    {
        $maxSize   = $this->config->get('media.max_file_size', 3);
        $validator = $this->getValidationFactory()->make($request->all(), [
            'file' => 'required|mimes:' . $this->getAcceptedFiles() . '|max:' . $maxSize * 1024,
        ]);

        if ($validator->fails()) {
            return response($validator->getMessageBag()->get('file')[0], 500);
        }

        $filename = trim($request->file('file')->getClientOriginalName());
        if (Storage::exists($request->input('current_directory') . '/' . $filename)) {
            return response($filename . " already exists.", 500);
        }

        Storage::put(
            $request->input('current_directory') . '/' . $filename,
            file_get_contents($request->file('file'))
        );

        return redirect()->back();
    }