we have some code for image upload and preview using jquery .Please see this fiddle and code .
https://jsfiddle.net/28v6vd23/1/
function readURL() {
var fileList = this.files;
var anyWindow = window.URL || window.webkitURL;
var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"];
for(var i = 0; i < fileList.length; i++){
var file_allow = fileList[i];
var fileType = file_allow["type"];
if ($.inArray(fileType, ValidImageTypes) > 0) {
var objectUrl = anyWindow.createObjectURL(fileList[i]);
var ran_x = Math.floor((Math.random() * 1000000000000) + 1);
$('.new').append('<div class="my-img-div" style="width:auto; display:inline-block;" ><img src="' + objectUrl + '" class="my-img" id="" /></div>');
window.URL.revokeObjectURL(fileList[i]);
}
}
}
var inputfile= document.getElementById("inputFile");
inputfile.addEventListener("change",readURL,false);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="form1" runat="server">
<input type='file' id="inputFile" />
</form>
<div class="new">
</div>
here for some images the image is previewing correctly ,
but for some images it is rotating 90 degree. Please check this .
Please check with this image https://drive.google.com/file/d/1UVW6dXMESAkeRFVxwBfsWWa4e9xD-DIL/view
How we can solve this ?
UPDATE
From @qvotaxon answer i can understand that https://github.com/blueimp/JavaScript-Load-Image this will help to solve the problem . But when i look into this i am struggling with the integration . If anyone can help the integration with my current code it will be really helpful .
Thank you