In the last tutorial, we covered how to handle file uploads in Ionic using the <input type="file">
element. This included using the file input element to grab a reference to a file and then upload that file to a Node/Express server (there is also an extension to the tutorial available where we build the backend with NestJS instead).
Those tutorials focused on a desktop/web environment, but what do we do to handle file uploads when our applications are deployed natively to iOS or Android? Can we still use <input type="file">
?
The answer to that question is mostly yes, but there are a few things to keep in mind.
If you have not already read (or watched) the previous tutorial, it would be a good idea to complete it before reading this one. The previous tutorial provides a lot of important context around how the HTML <input>
elements works when specifying the file
type, and also around how those files can be uploaded to a backend server with multipart/form-data
and the FormData
API.
#html #programming