I'm trying to dinamically preview an image in javascript before uploading it, so I got this code from here: Preview an image before it is uploaded
<input type="file" accept="image/*" onchange="loadFile(event)">
<img id="output"/>
<script>
var loadFile = function(event) {
var output = document.getElementById('output');
output.src = URL.createObjectURL(event.target.files[0]);
};
</script>
It works fine, but when I load a picture that's in portrait format, it rotates it automatically and sets it to landscape. How can I prevent that from happening?