Files on PATCH method

Not sure, but i found probably one strange behaviour. When i tried to check if request contains file/s, i always got an false or null on patch method. on post method i always got correct files…

– steps to reproduce
Create a simple multipart/form-data form with file upload with method patch
Submit form

try:
$request->hasFile(‘image’) or $request->file(‘image’) …

This is expected behavior - it’s a browser/HTTP limitation, not a Laravel or October bug. HTML multipart forms only work with POST.

Use method spoofing: keep method="POST" on your form and add <input type="hidden" name="_method" value="PATCH"> .

Laravel will route it as PATCH while preserving file uploads.

1 Like