I'm getting an image upload, or from the camera in an Angular app:
<button type="button" onclick="userData.store()">send now</button><br>
<input type="file" label="add photo" accept="image/*;capture=camera">
Then (for now) handling it with this Javascript:
var input = document.querySelector('input[type=file]');
var issuediv = document.getElementById('issue');
input.onchange = function () {
var file = input.files[0];
displayAsImage(file);
};
function displayAsImage(file) {
var imgURL = URL.createObjectURL(file),
img = document.createElement('img');
img.onload = function() {
URL.revokeObjectURL(imgURL);
};
img.src = imgURL;
issuediv.appendChild(img);
}
Two issues:
- This isn't Angular code—is what would be an Angular-ish way of handling the image and preparing it for the (MySQL) database via JSON?
- The above displays the image blob in Firefox and Chrome, but iOS and Android browsers don't appear to append the
imgtag and display only a tiny thumbnail.