public function UploadController::handleUploads in DropzoneJS 8
Same name and namespace in other branches
- 8.2 src/Controller/UploadController.php \Drupal\dropzonejs\Controller\UploadController::handleUploads()
Handles DropzoneJs uploads.
1 string reference to 'UploadController::handleUploads'
File
- src/
Controller/ UploadController.php, line 60
Class
- UploadController
- Handles requests that dropzone issues when uploading files.
Namespace
Drupal\dropzonejs\ControllerCode
public function handleUploads() {
$file = $this->request->files
->get('file');
if (!$file instanceof UploadedFile) {
throw new AccessDeniedHttpException();
}
// @todo: Implement file_validate_size();
try {
// Return JSON-RPC response.
return new AjaxResponse([
'jsonrpc' => '2.0',
'result' => basename($this->uploadHandler
->handleUpload($file)),
'id' => 'id',
]);
} catch (UploadException $e) {
return $e
->getErrorResponse();
}
}