providerService = $providerService; } /** * get - display upload form * * @throws \Exception * @throws \Exception */ public function get(): Response { return $this->tpl->displayPartial('csvImport.upload'); } /** * post - process uploaded file */ public function post(array $params): Response { $file = $this->incomingRequest->file('file'); try { $id = $this->providerService->processUpload($file); } catch (Exception $e) { return $this->tpl->displayJson(json_encode(['error' => $e->getMessage()]), 500); } return $this->tpl->displayJson(json_encode(['id' => $id])); } }