How to upload image using rest api in php

Using the REST API to upload a file to WordPress is quite simple.