Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70779

Can i have 2 filekey attribute in a FileUploadOptions parameter IONIC3?

$
0
0

@Vinayak wrote:

I want to upload 2 image file on the server, but unable to upload 2 image file in a same api. In JSON api there is 2 parameter which requires image file i.e id_proof_file_name and address_proof_name.

Rest Api function

register(imageidproof,imageaddproof, fullname, mobile_no, dob, address,
nominee_name,nominee_no, nominee_add, nominee_dob, scheme_type, installmentpending,
room_id, id_proof_type, id_proof_number, add_proof_type,  add_proof_number): Promise<any> {
    return new Promise((resolve, reject) => {
      let oPtions = {
        fileKey: 'id_proof_file',
        fileKey:'address_proof_file',
        params: {
          "full_name": fullname,
          "mobile_no": mobile_no,
          "dob": dob,
          "address": address,
          "nominee_name": nominee_name,
          "nominee_no": nominee_no,
          "nominee_add": nominee_add,
          "nominee_dob": nominee_dob,
          "scheme_type": scheme_type,
          "installmentpending": installmentpending,
          "room_id": room_id,
          "id_proof_type": id_proof_type,
          "id_proof_number": id_proof_number,
          "add_proof_type": add_proof_type,
          "add_proof_number": add_proof_number,
        },
        chunkedMode: false
      }

      let loading = this.loadCtrl.create({
        spinner: 'crescent',
        content: 'Please wait...',
        duration: 5000
      });
      loading.present();

      let bothimage = [];
      bothimage.push(imageidproof);
      bothimage.push(imageaddproof);

      console.log("POST DATA " + JSON.stringify(oPtions));
      console.log("IMage Data", bothimage.toString());
      const fileTransfer: FileTransferObject = this.transfer.create();

      fileTransfer.upload(bothimage.toString(), URL + 'registration', oPtions, true).then(data => {
        let result = this.helper.parseData(data.response);
        console.log("Response from server", result);
        loading.dismiss();
        this.checkForTokenFailure(result.status);
        if (result.response == "true") {
          resolve(result)
        } else {
          this.helper.showALert(2, result.message);
          resolve();
        }
      }).catch(err => {
        loading.dismiss();
        console.log("Something error happend", err);
        reject();
      })
    })
  }

and in upload function i tried to send the image in the array, but it through error string type is supported in this format.

I want to have 2 fileKey is it possible …?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70779

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>