danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.6k forks source link

Support for empty arrays. #1979

Open ghost opened 7 years ago

ghost commented 7 years ago

If an empty array is specified within the data object passed to Upload the addFieldToFormData won't add anything to the resulting formData. There's cases where the server needs to know if the user for example wants to update an array in a db model, like emptying a tag array.

On the server side one can check if the receiving field was an empty array:

if(!fields['skills'][0]) { // empty array }

I'm not sure if there's a more simple or straightforward way of doing this, let me know you thoughts.