user3555081 user3555081 - 1 year ago 52
PHP Question

Laravel form not returning input when I add 'files'=>true

I have a form looking like this:

{{ Form::open(array('route' => '', 'files' => true)) }}
{{ Form::text('title', null, [
]) }}
{{ Form::text('description', null, [
'placeholder' => 'Desc',
{{ Form::file('path') }}

{{ Form::submit('Save', [
'class' => 'btn btn-primary btn-lg pull-right'
]) }}
{{ Form::close()}}

The problem is that
in my controller returns an empty array if that
is in the form description, when I remove it, the problem goes away and
returns the usual, expected input.

Edit- I found out what the problem was. My server had terribly low post_max_size in php.ini, and apparently it clears all your post/get data if the file exceeds that limit.

Answer Source

If you are not receiving any POST data, you have to check for the post_max_size directive and comparing to how much POST data you are sending to the server.

As you already experienced, the behavior of having no post data is clearly described on the docs:

If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. , and then checking if $_GET['processed'] is set.

The solution is to increase the value for post_max_size, and/or also, upload_max_size or even memory_limit.