ajax로 formdata 보내기

[링크 : https://www.mkyong.com/jquery/jquery-ajax-submit-a-multipart-form/]



생성하기

[링크 : https://developer.mozilla.org/ko/docs/Web/API/FormData/FormData]


보는거 무지 복잡하네..

var formData = new FormData();

formData.append('key1', 'value1');

formData.append('key2', 'value2');


// Display the key/value pairs

for (var pair of formData.entries()) {

    console.log(pair[0]+ ', ' + pair[1]); 

[링크 : https://stackoverflow.com/questions/17066875/how-to-inspect-formdata]


+

var formData = new FormData();


formData.append('items', new Blob([JSON.stringify({

    name: "Book",

    quantity: "12"

})], {

    type: "application/json"

})); 

[링크 : https://stackoverflow.com/...multipart-form-data-with-a-different-content-type-on-each-parts-with-j]


+

var st = imagepath.replace(data:image/png or jpg; base64"/""); 

[링크 : https://stackoverflow.com/questions/22172604/convert-image-url-to-base64]

'Programming > javascript & HTML' 카테고리의 다른 글

canvas to blob  (2) 2018.10.25
자바스크립트 base64 인코딩, 디코딩  (0) 2018.10.24
js toHexString()  (0) 2018.10.23
jsmpeg div로 사용시 옵션  (0) 2018.10.18
js setinterval  (0) 2018.10.16
Posted by 구차니