Title: Create_post attachment
Last modified: August 31, 2016

---

# Create_post attachment

 *  Resolved [chriswang](https://wordpress.org/support/users/chriswang/)
 * (@chriswang)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/create_post-attachment/)
 * Hi guys
 * I am having hard time understand how to get the attachment working with the create_post.
   I have tried <input type=”file” name=”attachment”> that the documentation suggested
   and the post was successfully created but the attachments did not get upload.
 * Here are my codes:
 * PHP:
    include ‘jsonDecode.php’; if (isset($_POST[‘create-post’])) {
 *  $json_get_nonce_request = ‘[http://example.com/api/get_nonce/?controller=posts&method=create_post&#8217](http://example.com/api/get_nonce/?controller=posts&method=create_post&#8217);;
   
   $nonce = jsonDecode($json_get_nonce_request);
 *  $json_create_post_request = ‘[http://example.com/api/posts/create_post/?nonce=&#8217](http://example.com/api/posts/create_post/?nonce=&#8217);.
   $nonce[‘nonce’].’&status=publish&title=’. $_POST[‘post-title’] .”;
    $post = jsonDecode(
   $json_create_post_request);
 * }
 * in the body
    <form action=”” enctype=”multipart/form-data” method=”post”> <input
   type=”text” name=”post-title” placeholder=”title”> <input type=”file” name=”attachment”
   > <input type=”submit” name=”create-post” > </form>
 * Not sure if i’m doing right for the attachment
    Thank you very much.
 * [https://wordpress.org/plugins/json-api/](https://wordpress.org/plugins/json-api/)

The topic ‘Create_post 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

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

 * 0 replies
 * 1 participant
 * Last reply from: [chriswang](https://wordpress.org/support/users/chriswang/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/create_post-attachment/)
 * Status: resolved