File upload is a common feature in many web applications that was originally done using web forms with
The example below shows a file picker that returns the size of uploaded files.
onchange event listener is attached to the file picker:
Then, the file is obtained from the event object the listener provides – the first file in the files array is picked because we are dealing with single files.
Next, an Ajax call is made to the endpoint that expects a file upload. In this case, the file is:
Further logic, like notifying, the user can be done in the
.then block. If any HTTP errors are encountered, they are handled in the
View all Courses