I am developing an android app that give users ability to browse , register, login, post and comment to my wordpress blog using Rest Api .

I am trying now to add a way for users to update their avatars , but i have no idea how to upload media to my blog

add_action('rest_api_init', function () {

  register_rest_route( 'wp/v2', 'upload_image/',array(
                'methods'  => 'POST',
                'callback' => 'upload_image' )); });

function upload_image( $path ) {



WordPress has a built-in function Media Handle Permalink that you can use to create an entry of the file in the database. Media Handle Permalink deals with the POST request, writing to storage, and adding the attachment to the database. You can check the link that leads to the WordPress Codex to find out more on its uses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.