Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php
Строк: 37
<?php

namespace IlluminateFoundationHttpMiddleware;

use 
Closure;
use 
IlluminateHttpExceptionsPostTooLargeException;

class 
ValidatePostSize
{
    
/**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @return mixed
     *
     * @throws IlluminateHttpExceptionsPostTooLargeException
     */
    
public function handle($requestClosure $next)
    {
        
$max $this->getPostMaxSize();

        if (
$max && $request->server('CONTENT_LENGTH') > $max) {
            throw new 
PostTooLargeException;
        }

        return 
$next($request);
    }

    
/**
     * Determine the server 'post_max_size' as bytes.
     *
     * @return int
     */
    
protected function getPostMaxSize()
    {
        if (
is_numeric($postMaxSize ini_get('post_max_size'))) {
            return (int) 
$postMaxSize;
        }

        
$metric strtoupper(substr($postMaxSize, -1));
        
$postMaxSize = (int) $postMaxSize;

        return 
match ($metric) {
            
'K' => $postMaxSize 1024,
            
'M' => $postMaxSize 1048576,
            
'G' => $postMaxSize 1073741824,
            default => 
$postMaxSize,
        };
    }
}
Онлайн: 1
Реклама