From dac9f6ed79b34c4cd02aab7a054c7d6a15919e60 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Fri, 18 Oct 2019 13:29:57 +0100 Subject: [PATCH] FEAT #11954 TIME 0:15 improve control file size --- src/app/convert/controllers/ConvertPdfController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/convert/controllers/ConvertPdfController.php b/src/app/convert/controllers/ConvertPdfController.php index 42a4d606a23..d9edb644283 100755 --- a/src/app/convert/controllers/ConvertPdfController.php +++ b/src/app/convert/controllers/ConvertPdfController.php @@ -258,12 +258,14 @@ class ConvertPdfController } else { $fileAccepted = StoreController::isFileAllowed(['extension' => $ext, 'type' => $mimeType]); $maxFilesizeMo = ini_get('upload_max_filesize'); + $uploadMaxFilesize = StoreController::getBytesSizeFromPhpIni(['size' => $maxFilesizeMo]); $canConvert = ConvertPdfController::canConvert(['extension' => $ext]); if (!$fileAccepted) { return $response->withStatus(400)->withJson(['errors' => 'File type not allowed. Extension : ' . $ext . '. Mime Type : ' . $mimeType . '.']); - } elseif ($size/1024 > $maxFilesizeMo*1024) { - return $response->withStatus(400)->withJson(['errors' => 'File maximum size is exceeded ('.$maxFilesizeMo.' Mo)']); + } elseif ($size > $uploadMaxFilesize) { + $maximumSizeLabel = round($maxFilesizeMo / 1048576, 3) . ' Mo'; + return $response->withStatus(400)->withJson(['errors' => 'File maximum size is exceeded ('.$maximumSizeLabel.')']); } elseif (!$canConvert) { return $response->withStatus(400)->withJson(['errors' => 'File accepted but can not be converted in pdf']); } -- GitLab