Closed ghten closed 4 years ago
Currently, ngx-upload can upload a file without form when you put disableMultipart: true
. uploadAll
will upload the files one by one.
If you want to upload many files at the same time, I mean that we have to use multipart/form-data
.
Ngx-upload doesn't support this type of upload. Is that in fact your need ?
What I want to do is this Class xxxxx String Array Etc.. Files = uploader.queue but with the files
And I post this class, now I put this class but without files and I send the files after, but I need an id for saving the files. The best way is to put the files in the class and if it’s not possible, to put the id in uploadAll
So , you want a form (with string, number, array) + a Array of File[] ? It's a multipart/form-data. I can add this feature maybe this weekend but, currently, you can't do that.
Can you send me a piece of your code with the upload ?
It's not a form, it's a class. My code in component this.rfqservice.save(rfq).subscribe(data => { console.log(data.id); if (this.uploader.queue.length > 0) { this.rfqservice.upload(this.uploader,data.id); } }); rfq is the class not a form because in this screen I have data that cannot be in a form. In service upload(uploader: HttpClientUploadService, id) { uploader.uploadAll({ method: 'POST', url: this.cfg.url_backend + this.cfg.panelUrl + this.cfg.uploadrfq, }); } I need the ID but I cannot send it.
If you want to send your datas (your class) WITH a bunch of files, the only way to do that is the form multipart.
Currently , you can:
if (this.uploader.queue.length > 0) {
for (const fileItem of this.uploader.queue) {
fileItem.formData.append('id', id);
}
this.rfqservice.upload(this.uploader);
}
Thank you, it's work.
Hi @wKoza,
I cannot use uploadAll. I don’t send a form but a class and I have to put the files in that class. I have seen the .file but I don’t have the image. I need an array equivalent to file but with the image. There is a way to do it from ngx-upload?
Thanks