# \[SOLVED\] How to upload an image using POST API

**URL:** <https://forum.bubble.io/t/solved-how-to-upload-an-image-using-post-api/8889>\
**Category:** Questions\
**Created:** [December 20, 2016, 12:17am UTC](https://forum.bubble.io/t/solved-how-to-upload-an-image-using-post-api/8889 "2016-12-20T00:17:43Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![blueback09](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/blueback09/32/7122_2.png) [@blueback09](https://forum.bubble.io/u/blueback09)\
**Post date:** [December 22, 2016, 6:43pm UTC](https://forum.bubble.io/t/solved-how-to-upload-an-image-using-post-api/8889/18 "2016-12-22T18:43:57Z")

</div>

Hokay, so, here’s what seems to be working for me:

1. get your file (name and data)
2. isolate and url encode the filename (somefile.jpg)
3. base64 encode the filedata
4. put the filename into array1[filename]
5. put the filedata into array1[contents]
6. put “false” into array1[private] (I haven’t tried making it private and attached to a database thing yet)
7. put that array into array2[file] (I tried changing that but the server stopped accepting it, so apparently it has to be “file”)
8. put anything else you need into array2[], for example “some example text” into array2[example]
9. convert array to JSON (as required) what you end up with is something like this:  
array2={  
file={filename=file’s-name.jpg, private=false, contents=base64}  
example=some example text  
}
10. setup your API to recognize the “file” parameter as a file and the “example” parameter as text
11. change the headers to “Content-Type: application/json”

---

_[View the full topic](https://forum.bubble.io/t/solved-how-to-upload-an-image-using-post-api/8889)._
