jimmywarting / FormData

HTML5 `FormData` polyfill for Browsers and nodejs
MIT License
360 stars 102 forks source link

handle empty fileList #112

Closed jimmywarting closed 4 years ago

jimmywarting commented 4 years ago

I just notice from working with busboy that when submitting a empty filelist the default browser algoritm is to post a empty file with a empty filename

example:

<form id="$form">
  <input type="file", name="landscape">
</form>

<script>
  var fd = new FormData($form)
  console.log([...fd]) // [ ["landscape", <File name: "" size: 0> ] ]
</script>

This polyfill don't take that into consideration. it don't append a empty file

  var fd = new FormDataPolyfill($form)
  console.log([...fd]) // []

Appending or not appending a empty file don't bother me. I don't use this polyfill anyway ^^ If at least one person wants to see this being supported then i can fix it.

I would have preferred if the formdata + HTML's form submission algorithm didn't post a empty field anyway.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.