public function UploadController::handleUploads in DropzoneJS 8.2
Same name and namespace in other branches
- 8 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 {
/* @var \Drupal\Core\File\FileSystem $file_system */
$file_system = \Drupal::service('file_system');
// Return JSON-RPC response.
return new AjaxResponse([
'jsonrpc' => '2.0',
'result' => $file_system
->basename($this->uploadHandler
->handleUpload($file)),
'id' => 'id',
]);
} catch (UploadException $e) {
return $e
->getErrorResponse();
}
}