Title: create post &#8211; send attachment
Last modified: August 21, 2016

---

# create post – send attachment

 *  [dvirh](https://wordpress.org/support/users/dvirh/)
 * (@dvirh)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/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
 * js:
 *     ```
       $(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();
   
           $.ajax({
               url: url + "/create_post?nonce=*******&title=" + post_title + "&content=" + post_content,
               dataType: "json",
               success: function(data){
                   console.log(data);
               },
               error: function(data) {
                   console.log(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" />
           </form>
       ```
   
 * wordpress json api github page ([https://github.com/homicidewatch/wordpress-json-api](https://github.com/homicidewatch/wordpress-json-api))
   says it needs to have a input with “attachemnt” as a name for file input. But
   again, not working for some reason.
 * [https://wordpress.org/plugins/json-api/](https://wordpress.org/plugins/json-api/)

Viewing 1 replies (of 1 total)

 *  [vespino](https://wordpress.org/support/users/vespino/)
 * (@vespino)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/create-post-send-attachment/#post-5023261)
 * Have you been able to solve this? I’m also looking for a way to upload an attachment.

Viewing 1 replies (of 1 total)

The topic ‘create post – send attachment’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/json-api.svg)
 * [JSON API](https://wordpress.org/plugins/json-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api/reviews/)

## Tags

 * [attachment](https://wordpress.org/support/topic-tag/attachment/)
 * [json](https://wordpress.org/support/topic-tag/json/)

 * 1 reply
 * 2 participants
 * Last reply from: [vespino](https://wordpress.org/support/users/vespino/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/create-post-send-attachment/#post-5023261)
 * Status: not resolved