ngx-uploader
ngx-uploader copied to clipboard
Multiple upload inputs and passing different [options] for each input
I want more than one input with different options and urls like this:
`<input type="file"
ngFileSelect
[options]="options1"
(onUpload)="handleUpload($event)"
(beforeUpload)="beforeUpload($event)">
<input type="file"
ngFileSelect
[options]="options2"
(onUpload)="handleUpload($event)"
(beforeUpload)="beforeUpload($event)">`
Configuration for file upload I'm trying to do is:
`this.options1 = {
url: 'url for first input'
fieldName: 'first input field name',
method: 'PUT'
};
this.options2 = {
url: 'url for second input'
fieldName: 'second input field name',
method: 'PUT'
};
handleUpload(data): void {
if (data && data.response) {
data = JSON.parse(data.response);
this.uploadFile = data;
//code
}
}
fileOverBase(e:any):void {
this.hasBaseDropZoneOver = e;
}
beforeUpload(uploadingFile): void {
if (uploadingFile.size > this.sizeLimit) {
uploadingFile.setAbort();
alert('File is too large');
}
}`
This results in always picking up the latter options i.e 'options2' and 'options1' donot have any effect. How do I implement this, having different url and fieldname for input?
I'm getting burned by this as well. Anyone found a workaround?