Client -> Server 파일 전송

How the web works

Using XMLHttpRequest

  • Sending and Receiving Binary Data
    • 파일들을 여러 가지 형태로 읽을 수 있다. 그것을 XHR에서 지정을 해줄 수도 있고. 예를 들어 서버에서 .png 파일을 보내준다고 치면 XHR responseType을 arraybuffer, blob 등으로 지정을 하여서 파일을 원하는 형태로 받을 수 있음
  • XMLHttpRequest: send() method
    • send 메쏘드는 서버에 request를 보내주는 녀석인데 이 녀석은 다양한 형태의 parameter를 받는다. 이 형태중 하나가 FormData이다.
  • Form DataThe FormData interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the fetch(), XMLHttpRequest.send() or navigator.sendBeacon() methods. It uses the same format a form would use if the encoding type were set to "multipart/form-data".formData가, XHR 에 사용될 수 있구나
  • .Using FormData Objects
    • formData 타입의 객체를 사용하여서 어떻게 XHR request를 날릴 수 있는지 보여준다