Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

casc-or's avatar

$errors Won't Be Populated When File Can't Be Uploaded

I have a Laravel 5.3 site running in a local DEV WAMP environment and a PROD VPS through Forge and Digital Ocean.

I have a validator that redirects back with errors

if ($validator->fails()) {
    return redirect()->action('MemberController@licinfo', ['id' => $id])
        ->withErrors($validator)
        ->withInput();

And a Blade template to show them

@if($errors->any())
    <div class="alert alert-danger fade in">
        <a href="#" class="close" data-dismiss="alert">&times;</a>
    <ul>
    @foreach($errors->all() as $error)
        <li>{{ $error }}</li>
    @endforeach
    </ul>
    </div>  
@endif 

That gets included

@include('errors.list')

Here's my dilemma - in my local environment, this all works as expected, I get dismissable error blocks.

In my production environment, the errors don't display.

I'm tearing my hair out trying to figure out why.

My code is in Git, checked into the remote repository, and Forge is configured to quick deploy from the branch on checkins so I'm pretty certain the code on the production site is the same as my local copy.

Any suggestions as to what is going on here would be gratefully appreciated.

0 likes
3 replies
casc-or's avatar

So on inspection my local environment was running PHP 5.6 while the production was 7.1.0.5.

I changed the local environment to 7.0.4 (latest I had installed) and now I've got errors not displaying in either enviromment.

So now I think what I've stumbled onto is this

https://github.com/laravel/framework/issues/12335

What I'm perplexed by is that I started with Laravel in October 2016, but at thiat time it seems this issue would have been solved in 5.3?

afrayedknot's avatar

Do any $errors work in other parts of your app? Or is it just when there is a file upload (which is the error you linked to)?

Have you tried uploading a smaller file?

casc-or's avatar

See this red face here? This is me embarrassed.

This had nothing to do with $errors being passed to views.

The php.ini on my production server had upload_max_filesize = 2M the way it came out of the box.

So the 6M file was never getting to my validator (set at max:4096) to populate $errors and display them.

As soon as I set upload_max_filesize = 128M the file got to the validator where it produced the expected error messages.

The reason it worked in PHP 5.6 but not PHP 7 on my dev machine is that the 5.6 already had upload_max_filesize = 128M.

Posting this so the next person can find it.

Thanks for trying to help.

Please or to participate in this conversation.