Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
130 views
in Technique[技术] by (71.8m points)

node.js - I have to upload 5 images how to know each image in nodejs?

I am using angular-file-uploader library to upload 5 images from angular html it is

<angular-file-uploader [config]="afuConfig" (ApiResponse)="upload1($event)">
</angular-file-uploader>//image1

<angular-file-uploader [config]="afuConfig2 " (ApiResponse)="upload2($event) ">
</angular-file-uploader>//image2

this afuConfig executes a nodejs function. How can I know in nodejs which image is being upload image1 or image2?

afuConfig: AngularFileUploaderConfig = {
            
            multiple: false,
            formatsAllowed: '.jpg, .jpeg, .png, .gif',
            // maxSize: '50' ,
            uploadAPI:{
              url: 'http://localhost:3999/admin/' + 'upload-avatar'
              
            
              // headers:{
              //'Authorization': this.token,
              
              // }
              
            },
          
          
            theme: 'attachPin',
            hideProgressBar: false,
            hideResetBtn: true,
            hideSelectBtn: false,
            // attachPinText: ' Sube la imagen'
          };

I need to refactorize and use only one upload-avatar method in nodejs but I don't know how to get if image is image1 or image2 from the frontend (angular).

In the library documentation says that I must use a parameter in afuConfig

 afuConfig: AngularFileUploaderConfig = {
            
            multiple: false,
            formatsAllowed: '.jpg, .jpeg, .png, .gif',
            // maxSize: '50' ,
            uploadAPI:{
              url: 'http://localhost:3999/admin/' + 'upload-avatar',
              
              params: {
                'image': '1'
              }
              // headers:{
              //'Authorization': this.token,
              
              // }
              
            },

 params: {
           'image': '1'
         }

But I dont know how get the params in nodejs function

  var identifier = req.files.file0.params;// this doesnt work
question from:https://stackoverflow.com/questions/65833751/i-have-to-upload-5-images-how-to-know-each-image-in-nodejs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...