Files
old-web/app/views/publishPhotos.ejs
2020-02-13 17:08:49 +01:00

24 lines
588 B
Plaintext

<br>
<input type='file' />
<br>
<img id="myImg" src="#" alt="your image" height=200 width=100>
<script>
function imageIsLoaded() {
alert(this.src); // blob url
// update width and height ...
}
window.addEventListener('load', function() {
document.querySelector('input[type="file"]').addEventListener('change', function() {
if (this.files && this.files[0]) {
var img = document.querySelector('img'); // $('img')[0]
img.src = URL.createObjectURL(this.files[0]); // set src to blob url
img.onload = imageIsLoaded;
}
});
});
</script>