Image Upload Does Not Work

Asked

Viewed 138 times

1

I’m using cordova in order to pass my application WEB for Android. In my application Web upload images using basic HTML tags <ipnut type='file' >. when I install the application on Android can no longer upload images.

Someone has been through a similar experience ?

  • 1

    Hello friend you are using IONIC 2?

1 answer

1

There is a difference, first we need to understand what you are working with, but following.

You might as well have one <input type="file"> to upload the photo, but I recommend using Plugin of Camera.

You can use the Filetransfer to upload the image to the server.

Accessing the Galeria

navigator.camera.getPicture(uploadPhoto, function(message) {
 alert('Erro ao enviar');
 }, {
 quality: 100,
 destinationType: navigator.camera.DestinationType.FILE_URI,
 sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
 });

Upload to the server.

var ft = new FileTransfer();
 ft.upload(imageURI, "SUA URL", function(result){
 console.log(JSON.stringify(result));
 }, function(error){
 console.log(JSON.stringify(error));
 }, options);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.