0

I am trying to setup a upload for a string data by ONLY using javascript formdata without an actual form.

I have something like this.

var string = JSON.stringify(jsonfile);

var formdata = new FormData();

var stringBlob = new Blob([string]);
formdata.append('file', stringBlob);

The upload part:

  $http.post(‘myurl/upload’, formdata, {
         'headers' : {'Content-Type':'multipart/form-data' }})

The request payload for formdata

------WebKitFormBoundaryarzhWTykl2Z6sSZ1
Content-Disposition: form-data; name="file"; filename="stringBlob"
Content-Type: application/octet-stream
------WebKitFormBoundaryarzhWTykl2Z6sSZ1--

For some reason, it doesn’t work. It comes with 200 OK response on the request but I think it never does the upload. Can someone help me about this? Thanks a lot!

Jwqq
  • 997
  • 4
  • 14
  • 22

0 Answers0