In a post to his site Rob Allen explains how to handle file uploads in a PSR-7 structure, specifically illustrating with an example using the Slim (v3) framework.
Handling file uploads in Slim 3 is reasonably easy as it uses the PSR-7 Request object, so let's take a look.
He shows how to create a simple index route in a Slim application and render a view containing just a simple form with an upload field and submit button. When the form submits, he uses the getUploadedFiles
method on the Slim Request
object to get the file information for the upload. He also shows how to check for errors on the upload using the file data as an object and calling the getError
method.