fix issue with post max size = 0

fixes #453
This commit is contained in:
Sergio Brighenti 2022-06-19 20:20:21 +02:00
parent 67fdb89ce3
commit d21f678843

View file

@ -123,7 +123,9 @@ class UploadController extends Controller
*/
protected function validateFile(Request $request, Response $response)
{
if ($request->getServerParams()['CONTENT_LENGTH'] > stringToBytes(ini_get('post_max_size'))) {
$iniValue = ini_get('post_max_size');
$maxPostSize = $iniValue === '0' ? INF : stringToBytes($iniValue);
if ($request->getServerParams()['CONTENT_LENGTH'] > $maxPostSize) {
$this->json['message'] = 'File too large (post_max_size too low?).';
throw new ValidationException(json($response, $this->json, 400));