components photo (HTML5 canvas)
Copy link to clipboard
Copied
Hello everyone .. How are you?
I hope that you will be healthy and well-being and away from us Corona.
Please experts to help me .
Choose any image from the device ?
https://drive.google.com/drive/folders/1oFAxc49AuXqkGmPd-b4poiY4eu9ERQLa?usp=sharing
var root = this;
var putFile;
root.stop();
root.INS_PHO.addEventListener("click", function (e) {
root.PHO_1,
function (container) {
if (bitmapA)
container.removeChild(bitmapA);
bitmapA = new createjs.Bitmap(e.target.result);
setTimeout(function () {
container.addChild(bitmapA);
}, 0);
};
});
root.uploadImage = function (container, loadCallback) {
INS_PHO.addEventListener("change", function (e) {
if (e.currentTarget.files && e.currentTarget.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
loadCallback(container);
}
reader.readAsDataURL(e.currentTarget.files[0]);
} else {}
});
};
Copy link to clipboard
Copied
what is it that you're trying to do?
have the user select a local bitmap and then add that to the stage?
Copy link to clipboard
Copied
@kglad Yes, exactly
Copy link to clipboard
Copied
Copy link to clipboard
Copied
there are security issues with doing that. i did not know until i tried testing with this:
var fileSelector = document.createElement('input');
fileSelector.setAttribute('type', 'file');
fileSelector.setAttribute('onchange', 'displayPic()');
function f(e) {
fileSelector.click();
displayPic = function(){
displayPicture(fileSelector.value);
}
}
function displayPicture(imgPath) {
var image = new Image();
image.onload = onLoadF;
image.src=imgPath;
}
function onLoadF(e) {
var img = new createjs.Bitmap(e.target)
stage.addChild(img);
stage.update();
}
this.b.addEventListener("click",f);
Copy link to clipboard
Copied
Many thanks for trying to help me
I will try to solve it.
Copy link to clipboard
Copied
i don't think you can solve unless you use server-side code to handle the file upload.
Copy link to clipboard
Copied

