在ValidatePostSize.php第22行laravel中的PostTooLargeException
我正在尝试上传包含图片的表单.当我提交它.它显示了这个错误
ValidatePostSize.php第22行中的PostTooLargeException: 我该如何解决这个问题?
检查php.ini文件中的以下参数.
我曾多次遇到过这个问题,通常是因为max_file_size默认设置为2M. > max_file_size **编辑 1.为屏幕创建错误警报 @if (count($errors) > 0) <div class="alert alert-danger"> <strong>Whoops!</strong> There were some problems with your input.<br><br> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif 2.确定您将在预先确定的验证类中使用的验证器** 'max' => [ 'numeric' => 'The :attribute may not be greater than :max.','file' => 'The :attribute may not be greater than :max kilobytes.','string' => 'The :attribute may not be greater than :max characters.','array' => 'The :attribute may not have more than :max items.',], 这是我用来检查文件大小的验证规则. ** 4.创建您的请求文件** php artisan make:request yourRequest ** 5.更新您的请求文件** public function rules() { return [ 'profile_pic' => 'required|image|mimes:jpg|max:10',]; } 6.使用请求文件管理规则的任何一方提出请求. public function upload(RequestsyourRequest $request) 还要确保您的Controller使用其中的请求类,如下所示: use AppHttpRequests; 如果你这样做,你会有一个如下错误: 另一种选择是使用Image类缩小文件(如果是图像). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |