wymsee / cordova-imagePicker

Cordova Plugin For Multiple Image Selection
MIT License
407 stars 853 forks source link

maximumImagesCount is not work #254

Open zhujunwei opened 6 years ago

zhujunwei commented 6 years ago

On my iphone(ios 10 );The ImagePickerOptions : maximumImagesCount is not work. I can take any photos more than the maximumImagesCount i set;

ondrakoupil commented 6 years ago

The same here. iPhone 6 - iOS 10.3.3, iOS 10.2, iOS 11.3, both simulator and real device. It seems to me that maximumImagesCount parameter is not working on iOS platform.

saurabhschauhan commented 6 years ago

facing the same issue.

yeshchaubey commented 4 years ago

Please Try.

import { Component } from '@angular/core'; import { Crop } from '@ionic-native/crop/ngx'; import { ImagePicker } from '@ionic-native/image-picker/ngx'; import { FileTransfer, FileUploadOptions, FileTransferObject } from '@ionic-native/file-transfer/ngx';

@Component({ selector: 'app-home', templateUrl: 'home.page.html', styleUrls: ['home.page.scss'], }) export class HomePage {

fileUrl: any = null; respData: any;

constructor(private imagePicker: ImagePicker, private crop: Crop, private transfer: FileTransfer) { } public options: any = { allowEdit: true, maximumImagesCount: 1, outputType: 0,
} cropUpload() { this.imagePicker.getPictures(this.options).then((results) => { for (let i = 0; i < results.length; i++) { console.log('Image URI: ' + results[i]); this.crop.crop(results[i], { quality: 100 }) .then( newImage => { console.log('new image path is: ' + newImage); const fileTransfer: FileTransferObject = this.transfer.create(); const uploadOpts: FileUploadOptions = { fileKey: 'file', fileName: newImage.substr(newImage.lastIndexOf('/') + 1) };

            fileTransfer.upload(newImage, 'http://192.168.0.7:3000/api/upload', uploadOpts)
             .then((data) => {
               console.log(data);
               this.respData = JSON.parse(data.response);
               console.log(this.respData);
               this.fileUrl = this.respData.fileUrl;
             }, (err) => {
               console.log(err);
             });
          },
          error => console.error('Error cropping image', error)
        );
  }
}, (err) => { console.log(err); });

} }