valor-software / ng2-file-upload

Easy to use Angular components for files upload
http://valor-software.github.io/ng2-file-upload/
MIT License
1.91k stars 662 forks source link

Upload without file #732

Open thc0309 opened 7 years ago

thc0309 commented 7 years ago

Hi there. How can i submit without file uploader ?

AmirAliSobhGol commented 7 years ago

you are not asking the right question, you want to know how to send form-data requests. here is a code snippet


xhrTransport(data) {
    let xhr = new XMLHttpRequest();
    let formData = new FormData();
    let field;
    for (field in data)
      formData.append(field, data[field])
    xhr.open('POST', API_URL);
    xhr.setRequestHeader('Authorization', localStorage.getItem(TOKEN_NAME));
    xhr.send(formData);
  }