Reputation: 45
I have a form looking like this:
{{ Form::open(array('route' => 'notebook.store', 'files' => true)) }}
{{ Form::text('title', null, [
'class'=>'form-control',
'placeholder'=>'Title',
]) }}
<br>
{{ Form::text('description', null, [
'class'=>'form-control',
'placeholder' => 'Desc',
])}}
<br>
{{ Form::file('path') }}
<br>
{{ Form::submit('Save', [
'class' => 'btn btn-primary btn-lg pull-right'
]) }}
<br><br>
{{ Form::close()}}
The problem is that Input::all()
in my controller returns an empty array if that 'files'=>true
is in the form description, when I remove it, the problem goes away and Input::all()
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.
Upvotes: 4
Views: 6894
Reputation: 1645
{!! Form::open(['url' => 'notebook.store', 'method' => 'post', 'enctype' => 'multipart/form-data']) !!}
<div class="form-group">
{!! Form::file('logo', null, ['class' => 'form-control']) !!}
</div>
{!! Form::submit('Upload', ['class' => 'btn btn-primary']) !!}
Upvotes: 0
Reputation: 189
Its not working because you are adding files=>true to the route array:
{{ Form::open(array('route' => 'notebook.store', 'files' => true)) }}
Instead try this
{{ Form::model(array('route'=>array('notebook.store'),'files'=>true)) }}
Upvotes: 0
Reputation: 2541
Use this:
{{ Form::open(array('route' => 'notebook.store', 'enctype' => 'multipart/form-data')) }}
For any reason this:
{{ Form::open(array('route' => 'notebook.store', 'files' => true)) }}
does not work!
Upvotes: 5
Reputation: 29251
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
.
Upvotes: 2