简体   繁体   中英

Image Upload then automatically image are rotate in Preview Image tag?

I am uploading the image in file upload control on change event then image is automatically rotate see in preview tag in my asp.net mvc c# but I am upload the existing image upload it's good but I am click the image in iPhone then image are upload that time image is rotate. This below code is used for the preview image.

This is my file upload control

 <img id="PreviewImage" class="mb20" width="300" src="../@Url.Content(@Url.Content(Model.ProfileImage))" />                                        
  @Html.TextBoxFor(model => model.UserFileUpload, new { type = "file", onchange = "ShowVehicleImagePreview(this)" })

this is my function

function ShowVehicleImagePreview(input) {
    if (input.files && input.files[0]) {
        var readervehicle = new FileReader();
        readervehicle.onload = function (e) {
            $('#PreviewImage').prop('src', e.target.result).width(300);
        };
        readervehicle.readAsDataURL(input.files[0]);
    }
}

Any one have the idea about this issue?

Maybe the image file it self has orientation metadata and the iPhone show it to you as correctly rotated because it's correcting the image, maybe this answer can help:
How to rotate JPEG images based on the orientation metadata?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM