Angularjs Angularjs 2 Ionic 2

Ionic image upload or capture and store

Ionic image upload or capture and store

In this tutorial we are going to see how to upload a image or capture and store a image from camera using ionic 2. Sometimes we need to get user avatar from profile. In this case we need to get a picture or capture a picture from user. Lets see how to achieve this.

Step 1 : Install Ionic 2 application

Step 2 : Install required plugins for capture and upload

a) Camera -> Used to access your camera

b) File -> Used to copying the camera result into filesystem

c) Filetransfer -> Used to upload a files

d) Filepath -> Used to resolve the native filepath

Install all the plugins.

Sometimes Camera Plugin will not install in android platform. Because of old cordova android platform version. To fix this, Update your android version in cordova globally or update for this particular app by running below comment

Once you update please dont forget to unistall and reinstall cordova-plugin-camera plugin.



Fo iOS you need to use below lines in config.xml for iOS Quirks

Step 3 : Import plugins in app.module.ts

Step 4 : Import above plugins in ts where you want to upload

profile.ts

upload.php

Output :

Ionic image upload or capture and store

Hope it will help someone else also thanks.