0

Using WP drag/drop upload, the request payload (via Chrome DevTools) as below :

------WebKitFormBoundary
Content-Disposition: form-data; name="name"

butterfly.jpg
------WebKitFormBoundary
Content-Disposition: form-data; name="action"

upload-attachment
------WebKitFormBoundary
Content-Disposition: form-data; name="_wpnonce"

abc123
------WebKitFormBoundary
Content-Disposition: form-data; name="async-upload"; filename="butterfly.jpg"
Content-Type: image/jpeg


------WebKitFormBoundary--

Is it possible to add more field to this? without using plugins?

0

not without creating your own custom form. There are 2 ways to achieve this,

  1. uploading attachments in the post editor, In your post edit page you can create a custom metabox which will allow you to enter custom fields for your posts. When you save your post, you can hook into the backend saving process using the save_post action and look for your custom fields in the $_POST array of submitted fields. You can also capture the attachment id in case you want to attach your custom fields to the attachment itself.
  2. Creating a custom admin page with am uploader, alternatively you can create a custom admin page and setup your own attachment uploader and custom fields. See this little video tutorial for more details.

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.