Support » Plugin: JSON API » create post – send attachment

  • I’m building a web application based on wordpress & wp json plugin.

    I created a form for posting a new post with title, content and attachment but the attachment is not passing on


    $(document).on("submit", "#add-post #post-upload", function(e) {
        var post_title = $("#add-post input[name='form-post-title']").val();
        var post_content = $("#add-post textarea[name='form-post-content']").val();
            url: url + "/create_post?nonce=*******&title=" + post_title + "&content=" + post_content,
            dataType: "json",
            success: function(data){
            error: function(data) {

    html code:

    <form name="post-upload" id="post-upload" method="post" action="#home" enctype="multipart/form-data">
            <input type="text" name="form-post-title" placeholder="title" />
            <textarea name="form-post-content" placeholder="content"></textarea>
            <input type="file" name="attachment" id="attachment" />
            <input type="submit" value="Submit" />

    wordpress json api github page ( says it needs to have a input with “attachemnt” as a name for file input. But again, not working for some reason.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘create post – send attachment’ is closed to new replies.