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
– DiegoAugusto
Sorry Diegoaugusto did not understand how to do this, could leave an example?
– Ronaldo.G
The question is somewhat confusing.
– Otto
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.– Anthony Accioly