2

I would like to figure out a way to append blob to FormData without being forced to add an implicit filename.

formData.append('binary_data', blobObj) always creates a default filename for the key binary_data.

I tried the following code, in order to avoid the implicit filename:

formData.append('binary_data', blobObj, null);

But it turned out to create the filename "null", as the request content shows:

...
Content-Disposition: form-data; name="binary_data"; filename="null"
...

Because of the existence of the filename, the PHP backend automatically saves the binary data as a temporary file, and adds the file information to the $_FILES array. I would like to figure out a way to post blob as FormData without being forced to add an implicit filename, so that the PHP backend can directly save the binary data in $_POST['binary_data'] instead of $_FILES['binary_data'].

Any idea? Thanks!

Amit Verma
  • 8,660
  • 8
  • 35
  • 40
張俊芝
  • 187
  • 1
  • 9

0 Answers0