Skip to content

Instantly share code, notes, and snippets.

@jedmarcnocum
jedmarcnocum / upload-a-file.MD
Created February 19, 2019 16:18 — forked from ahmadawais/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

a1c8a515048b6cde254c314d00d9977dba506740