src/Zf2FileUploader/Controller/AbstractCreateController.php
public function dispatch(Request $request, Response $response = null)
    {
        $this->request = $request;
        $this->getDataResourceCreator()->setData(array_merge_recursive($this->params()->fromPost(),
                                                                       $request->getFiles()->toArray()));


        if (!$this->getDataResourceCreator()->isValid()) {
            if ($this->disableDefaultErrorHandler) {
                $response = $response ?: new HttpResponse();
                $this->getEventManager()->clearListeners(MvcEvent::EVENT_DISPATCH);
                $this->getEvent()->setResult(false);
                $response->setStatusCode(400);
            } else {
                $this->getEventManager()->clearListeners(MvcEvent::EVENT_DISPATCH);
                $this->uploaderModel->setMessages($this->getDataResourceCreator());

                $this->getEvent()->setResult($this->uploaderModel);
            }
        }

        parent::dispatch($request, $response);
    }
public function dispatch(Request $request, Response $response = null)
    {
        $this->request = $request;
        $this->getDataResourceCreator()->setData(array_merge_recursive($this->params()->fromPost(),
                                                                       $request->getFiles()->toArray()));


        if (!$this->getDataResourceCreator()->isValid()) {
            if ($this->disableDefaultErrorHandler) {
                $response = $response ?: new HttpResponse();
                $this->getEventManager()->clearListeners(MvcEvent::EVENT_DISPATCH);
                $this->getEvent()->setResult(false);
                $response->setStatusCode(400);
            } else {
                $this->getEventManager()->clearListeners(MvcEvent::EVENT_DISPATCH);
                $this->uploaderModel->setMessages($this->getDataResourceCreator());

                $this->getEvent()->setResult($this->uploaderModel);
            }
        }

        parent::dispatch($request, $response);
    }
Dispatch a request

@events dispatch.pre, dispatch.post
@param  Request $request
@param  null|Response $response
@return Response|mixed