From f577becb295fa08ac2bd25599def2dbf171e9a6d Mon Sep 17 00:00:00 2001 From: Matthew McSparran Date: Wed, 20 Dec 2017 10:39:37 -0500 Subject: [PATCH] Updated docs The README has been updated to include information on adding extra fields to uploads when uploading multiple files. --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/README.md b/README.md index a422bdf..b85c925 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,63 @@ Easy to use Angular2 directives for files upload ([demo](http://valor-software.g ```public uploader:FileUploader = new FileUploader({url: URL}); ``` +## Using ***ng2-file-upload*** with multiple uploads and other parameters +To add extra information (i.e. title, description) when uploading multiple files: + +In your template: +``` + + {{ item?.file?.name }} + + **** + **** + {{ item?.file?.size/1024/1024 | number:'.2' }} MB + +
+
+
+ + + + + + + + + + + + + +``` +You can add inputs outside of a form, and use ```[(ngModel)]``` to add keys to the ```item``` object. + +``` + **** + **** +``` +Inside your upload component, add the following: + +``` + this.uploader.onBuildItemForm = (item, form) => { + form.append('title', item.formData.title); + form.append('description', item.formData.description); + console.log(item); + }; + +``` +If you are using `Node.js` with `multer`, the extra information will not show up in the `req.files` object. You will have to pull the data from the `req.body` object. + + ## API for `ng2FileSelect` ### Properties