Open jgw96 opened 7 years ago
From @PterPmnta on April 18, 2017 17:22
Previously I could add the path of an image after converting it to Base64 even Input to then be shown in a DIV, but after a while in trying to perform the process does not allow me to do that action and I get the following message:
https://i.stack.imgur.com/qGSce.jpg
angular.module('perfilEstudiante', ['ionic', 'ngCordova']) .controller('mostrarPerfilEstu', mostrarPerfilEstu) .directive('pickFile', pickFile) .factory('obtenerPerfilEstu', obtenerPerfilEstu); mostrarPerfilEstu.$inject = ['$scope', 'obtenerPerfilEstu']; function mostrarPerfilEstu($scope, obtenerPerfilEstu, $element) { var Perfil, Mes, Periodo_Estu, input, button, evtHandler, dataImage; dataImage = localStorage.getItem("imgData"); if (dataImage === null) { $scope.dataImage = "img/profile_icon.png"; } else { $scope.dataImage = "data:image/png;base64," + dataImage; } $scope.loadImage = function (file) { if (file.type.indexOf('image') < 0) { $scope.res = "Tipo inválido"; $scope.$apply(); return; } var fReader = new FileReader(); fReader.onload = function () { var data = fReader.result; $scope.dataImage = data; $scope.res = ""; $scope.$apply(); localStorage.setItem("imgData", data.replace(/^data:image\/(png|jpe?g);base64,/, "")); }; fReader.readAsDataURL(file); }; }; function pickFile() { return { restrict: 'EA', scope: { onselected: "&" }, template: '<button class="button button-icon icon ion-plus-round pull-right">' + '<input type="file" style="display: none !important">' + '</button>', link: function ($scope, $element) { var input = $element.find('input'); var button = $element.find('button'); var evtHandler = function () { input[0].click(); }; button.on('click', evtHandler) input.on('change', function () { var file = input[0].files[0]; $scope.onselected({ file: file }); }); } }; };
Android version in my smartphone is 4.2.2
Copied from original issue: driftyco/ionic#11258
From @rapropos on April 18, 2017 23:7
Should probably be rerouted to v1.
@jgw96 i solved this problem, i am using now the camera plugin for take picture from gallery work perfect.
From @PterPmnta on April 18, 2017 17:22
Previously I could add the path of an image after converting it to Base64 even Input to then be shown in a DIV, but after a while in trying to perform the process does not allow me to do that action and I get the following message:
https://i.stack.imgur.com/qGSce.jpg
Android version in my smartphone is 4.2.2
Copied from original issue: driftyco/ionic#11258