フレームワークでlaravelを使ったプログラムで、ファイルサイズが159Kのファイルをpostしした際にPostTooLargeExceptionエラーが出ました。その時のpost_max_sizeの設定は8Mでした。
このエラーの原因を突き止めて欲しいとの依頼が来ました。
しかしエラーが再現出来ないので、原因がさっぱり分かりません。
原因が分かるかたいらっしゃいましたら教えて頂きたいです。
エラー内容
production.ERROR: Illuminate\Http\Exceptions\PostTooLargeException in ...vendo r/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.p hp:24
ValidatePostSize.phpのコード
<?php namespace Illuminate\Foundation\Http\Middleware; use Closure; use Illuminate\Http\Exceptions\PostTooLargeException; class ValidatePostSize { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed * * @throws \Illuminate\Http\Exceptions\PostTooLargeException */ public function handle($request, Closure $next) { $max = $this->getPostMaxSize(); if ($max > 0 && $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)); switch ($metric) { case 'K': return (int) $postMaxSize * 1024; case 'M': return (int) $postMaxSize * 1048576; case 'G': return (int) $postMaxSize * 1073741824; default: return (int) $postMaxSize; } } }
補足
・以下でExceptionを吐いているよう。
if ($max > 0 && $request->server('CONTENT_LENGTH') > $max) { throw new PostTooLargeException; }
・ValidatePostSize.phpのhandleメソッドは、リクエストされるたびに呼ばれる。
・ini_get('post_max_size')
の値は8388608
(8M)
・$request->server('CONTENT_LENGTH')
の値は163380
(159K)
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー