I’m mostly a PHP backend / HTML/CSS frontend developer, so I’ve always sent images to my server from the client using either form enctype: multipart/formdata or through a FormData object when uploading through ajax requests. After that I would receive the file in the $_FILES array.
Lately I’ve been working with REST APIs and I’ve been doing some research about sending files. I’m trying to build an app using Flutter, so I need a way to send files to my API. The thing is I don’t know the best way to do it, should I encode images in Base64? Is there any alternative to doing this? How about other types of files? At the time of writing this I’ve noticed that I don’t even know how PHP manages to receive files, does it encode them?
Finally my question would be, which are the ways of sending files / images to a REST API? How to encode them if needed? And as a plus is anyone knows how PHP handles the connection between a form and the FILES array it would be quite helpful!
Source: Ask PHP