image download

Murugesan Manokaran asked on December 4, 2017 17:55

we have developed a custom media gallery with the images from corporate Sharepoint Online location. click on the image the user can download the image for their official presentation use. this works fine in chrome (we are using . Not working with IE.

Is there any way to resolve this issue?

Correct Answer

Murugesan Manokaran answered on December 4, 2017 18:15

found the issue and fixed. Thanks.

changed lines: window.navigator.msSaveBlob(canvas.msToBlob(), imgFileName); img.src = imgFileName;

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on December 4, 2017 18:01

What have you done or tried to resolve the issue for IE? Can you share what your download link looks like or what you're doing to allow them to download the image/resource?

0 votesVote for this answer Mark as a Correct answer

Murugesan Manokaran answered on December 4, 2017 18:10

here is the k# code with the javascript at the top <script type='text/javascript'> //download image file from IE function downloadFile(obj){

var imgFileName = $(obj).attr('src');

var canvas = document.createElement('canvas');
var img = document.createElement('img');
img.onload = function (e) {
    canvas.width = img.width;
    canvas.height = img.height;
    var context = canvas.getContext('2d');
    context.drawImage(img, 0, 0, img.width, img.height);
    window.navigator.msSaveBlob(canvas.msToBlob(), "'"  + imgFileName + "'");
}
img.src = "'"  + imgFileName + "'";

}

=============================K#========================== print("<div id='dvImage' style='width:120px !important;height:auto'>"); if(BrowserInfo.IsIE) {
print(""); print("<img src='" + doc.ThumbnailUrl + "' style='width:100px !important;height:50px' onclick='downloadFile(this);' />"); print(""); } else { print("<a download='" + doc.Url + "' href='" + doc.Url + "'>"); print("<img src='" + doc.ThumbnailUrl + "' style='width:100px !important;height:50px' />"); print(""); } print("");
}

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.