0

I'm building a simple website that allows image uploading. I'm trying to understand how can I allow the user to upload an image to my server.

I'm asking this question in two aspects:

  1. How is that happening behind the scenes? an HTTP POST request must be sent and I assume that the image is being sent as part of the body. But is it just the bytes that are sent? or is the image being encoded before POSTing? How is Base64 has to do with all of this (if at all)?

  2. How can I implement it using pure Javascript (and maybe the Fetch library) only? I'm using NodeJS in the backend. I have googled this subject and found many examples using jQuery or PHP (as backend). I prefer not using jQuery at all.

Thanks

johni
  • 5,342
  • 6
  • 42
  • 70
  • 1
    See [How does HTTP file upload work?](http://stackoverflow.com/questions/8659808/how-does-http-file-upload-work) – Alex K. Apr 16 '16 at 15:15
  • See [JavaScript: Upload file](http://stackoverflow.com/questions/5587973/javascript-upload-file) – Alex K. Apr 16 '16 at 15:17
  • [Sending multipart/formdata with jQuery.ajax](http://stackoverflow.com/questions/5392344/sending-multipart-formdata-with-jquery-ajax) has some better answers on uploading files with JS. – Quentin Apr 16 '16 at 15:23

0 Answers0