4

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.

4
  • I tried to add 'files' => true to one of my forms, and there was no problem with Input::all(). This option just adds enctype="multipart/form-data" to the <form> element. Commented Apr 21, 2014 at 0:45
  • Could be something server related, although I'm not sure what. Is it only when you add a file to upload or is it just always returning an empty array? Commented Apr 21, 2014 at 0:47
  • Is Input::file('path') in your controller empty? Commented Apr 21, 2014 at 3:36
  • I tried with both empty and populated 'path' field, in both cases the Input::all() array is empty Commented Apr 21, 2014 at 9:11

4 Answers 4

5

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!

Sign up to request clarification or add additional context in comments.

1 Comment

{!! Form::model($article,array('method' => 'PATCH','route'=>array('articles.update',$article->id),'files' => true)) !!} i have used this, but doesn't work
2

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.

Comments

0

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)) }}

Comments

0
    {!! 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']) !!}

1 Comment

Can you add an explantion, why your idea woll solve the issue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.