3 ms·
const input = document.createElement("input"); document.body.append(input); input.type = "file"; input.accept = "image/*"; input.onchange = e =>
by creata 1y ago
const input = document.createElement("input");
document.body.append(input);
input.type = "file";
input.accept = "image/*";
input.onchange = e => {
if (input.files && input.files[0]) {
const canvas = document.getElementById("draw-canvas");
const ctx = canvas.getContext("2d");
createImageBitmap(input.files[0]).then(img => ctx.drawImage(img, 0, 0));
}
};