How to exchange Angularjs avatar using Storage image?

Asked

Viewed 242 times

1

Creating an app with Angularjs and would like the user to choose a photo of his Image Gallery to insert as an image of his profile, I want to search the image in the internal memory. It is possible?

$scope.pegaArquivo = function (files) {
    var imgLocal = document.getElementById('imgLocal')
    var file = files[0];
    var img = document.createElement("img");
    img.file = file;

    localStorage.setItem('object',JSON.stringify(file)); 
    this.quickOrder.push(JSON.parse(localStorage.getItem('object')));
    return file;

    imgLocal.appendChild(img)

    var reader = new FileReader();
    reader.onload = (function (aImg) { return function (e) { aImg.src = e.target.result; }; })(img);
    reader.readAsDataURL(file);
}
  • Yes, just you recover the list of images that is in Localstorage, make available to the user choose to pass the id of the image chosen pro getItem

  • Sorry Diegoaugusto did not understand how to do this, could leave an example?

  • The question is somewhat confusing.

  • Hello Ronaldo, from what I understand you are first seeking to save an image in Storage and then retrieve it to display in a tag img, is that it? If so, take a look in Soen’s reply.

No answers

Browser other questions tagged

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