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

timgavin's avatar

hasFile() no longer works

This was working perfectly under 5.3.

I just upgraded to 5.4 and can no longer upload files using the hasFile() method. The check is ignored

public function addPhotos(Request $request)
{
    // dd($request) here shows a file in the fileBag

    if ($request->hasFile('photo'))
    {
        // dd($request) here never prints, this block is passed over as if the file doesn't exist
    }
}

Any ideas?

0 likes
5 replies
timgavin's avatar

League/flysystem is part of the core, isn't it? Shouldn't it be updated automatically? I don't see a reference to it in composer.json.

jekinney's avatar

Yes but sometimes it may not for whatever reason. For example when I deploy I hard code the exact release version just in case someone clones the master and then has issues like your having on the upgrade.

timgavin's avatar

How would you suggest I do this? Wouldn't running composer require league/flysystem install it outside of the core?

timgavin's avatar

After more testing it appears that the file I was trying to upload was not valid, which is weird because I've been able to not only open and view it, but upload it to Twitter.

Don't know why Laravel thinks it's not a valid JPG...

Thanks for your help, @jekinney :)

1 like

Please or to participate in this conversation.