21 public function __invoke(Request $request, Response $response, $args)
23 $directory =
'/data/scan';
25 $uploadedFiles = $request->getUploadedFiles();
28 foreach ($uploadedFiles as $uploadedFile) {
29 if ($uploadedFile->getError() === UPLOAD_ERR_OK && $uploadedFile->getClientMediaType() ==
'application/pdf') {
31 $response->withStatus(200);
46 $extension = pathinfo($uploadedFile->getClientFilename(), PATHINFO_EXTENSION);
47 $basename = bin2hex(random_bytes(8));
48 $filename = sprintf(
'%s.%0.8s', $basename, $extension);
50 $uploadedFile->moveTo($directory . DIRECTORY_SEPARATOR . $filename);
__construct(LoggerInterface $logger)
moveUploadedFile($directory, UploadedFile $uploadedFile)
__invoke(Request $request, Response $response, $args)