Reference 1st : https://www.youtube.com/watch?v=XTao_pQALLg
code in post-text of "FILE BROWSER" :
<canvas id="image-preview" width="100" height="50" style="border:1px solid #000000;">
Dynamic Action of "File Browser": CHANGE AND JAVA SCRIPT CODE :
try {
var canvus =$x('image-preview');
var ctx = canvus.getContext('2d');
var img = new Image;
img.src = window.URL.createObjectURL(this.triggeringElement.files[0]);
img.onload = function() {
if (img.width > 200) {
canvus.style.width = "100px";
}
canvus.width = img.width;
canvus.height = img.height;
ctx.drawImage(img,0,0);
$("#container-img-preview").show();
}
} catch (e) {
console.log(e);
}
code in post-text of "FILE BROWSER" :
<canvas id="image-preview" width="100" height="50" style="border:1px solid #000000;">
Dynamic Action of "File Browser": CHANGE AND JAVA SCRIPT CODE :
try {
var canvus =$x('image-preview');
var ctx = canvus.getContext('2d');
var img = new Image;
img.src = window.URL.createObjectURL(this.triggeringElement.files[0]);
img.onload = function() {
if (img.width > 200) {
canvus.style.width = "100px";
}
canvus.width = img.width;
canvus.height = img.height;
ctx.drawImage(img,0,0);
$("#container-img-preview").show();
}
} catch (e) {
console.log(e);
}
0 comments:
Post a Comment