【问题标题】:Laravel PostTooLargeExceptionLaravel PostTooLargeException
【发布时间】:2018-09-07 19:35:42
【问题描述】:

无论我更改我的 php.ini 并验证视频上传多少次,我总是从 Laravel 收到一个错误,说 PostTooLargeException。

这是在我的控制器中:

'video' => 'required|mimes:mp4,flv,wmv,avi,mov,qt|max:100000',
'city'  =>'required',

这是表格:

{!!Form::open(array('route'=>'profile.store','class'=>'formform','files'=>'true','method'=>'POST','enctype' => 'multipart/form-data')) !!}

{{Form::text('city','',array('placeholder'=>'City and State','class'=>'form-control', 'size'=>'35px','height'=>'15px','id'=>'location-input','autocomplete'=>'off'))}}
{{Form::file('video',array('id'=>'file','class'=>'thefile'))}}


{{Form::submit('Submit', array('class'=>'btn btn-danger form-control','id'=>'submitty','style'=>'  background:#F88B22;'))}}
{!!Form::close() !!}

这是我的路线:

Route::resource('profile','ProfileController',['except'=>'edit']);
Route::get('editlisting/{companyname}','ProfileController@edit');

【问题讨论】:

  • 我认为最大验证规则不是以兆字节为单位的。
  • 这里是您的解决方案tjd-studio.com/blog/article/…
  • 调试ValidatePostSize::handle()$max的值是多少?
  • @JonasStaudenmeir 我想我现在明白了。但我有一个问题。 laravel 应该验证文件 'video' => 'required|mimes:mp4,flv,wmv,avi,mov,qt|max:100000',但它没有这样做,我只是不断收到 PostTooLargeException。我知道文件很大,但我验证了它。这里发生了什么?
  • 文件有多大?

标签: laravel php-ini


【解决方案1】:

upload_max_filesize 的值不能大于 php.ini 文件中的 post_max_size

【讨论】:

  • 我会确保的。我有个问题。当我上传时执行时间很慢,有什么办法可以加快速度吗?
【解决方案2】:

嗨,你可以这样做,

确保您的表单中有enctype=multipart/form-data

 'video' => 'file|mimes:mp4,flv,wmv,avi,mov,qt|max:10240',

您必须在验证其大小时使用file

希望对你有帮助

【讨论】:

  • 我做了它仍然做同样的事情
  • 我可以压缩文件吗?如果是这样,我该怎么做?
  • 我刚刚编辑了所有我添加的表单控制器和表单代码看看
  • @Stephany.S123 也发布您的路线
  • lerval 我刚刚做了
猜你喜欢
  • 1970-01-01
  • 2019-08-31
  • 1970-01-01
  • 2021-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-05
相关资源
最近更新 更多