首页 > 解决方案 > Laravel文件上传错误Content-Length

问题描述

错误

Warning: POST Content-Length of 31492035 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

应用程序.php

'allowedFileTypes' => 'jpg,jpeg,bmp,png,pdf,mp4',
'maxFileSize' => 10000000000*2,

控制器创建

$rules = ['attachments.*' => 'required|mimes:'.$allowedFileTypes.'|max:'.$maxFileSize];
Storage::put($destinationPath.$fileName.'.'.$file->getClientOriginalExtension(),file_get_contents($file->getRealPath()));

标签: laraveleloquent

解决方案


8388608 字节为 8M,PHP 中的默认限制。将您的 in php.ini 更新post_max_size为更大的值。

upload_max_filesize设置用户可以上传的最大文件大小,而 post_max_size 设置可以通过表单中的 POST 发送的最大数据量。

所以你可以做得upload_max_filesize更大。


推荐阅读