javascript - HTML5 Canvas toDataUrl - Upload gif workaround -
i'm wondering if it's possible preview .gif image within canvas element , uploaded 'image/gif' file type. found so question, incorrectly mentions .gif in title no references on how deal canvas , gifs within of responses/comments.
according docs, 'image/gif' not accepted type todataurl. there workaround / lib allow me place gif within preview canvas , upload canvas file gif?
filereader.readasdataurl()
from mozilla.org
function previewfile() { var preview = document.queryselector('img'); var file = document.queryselector('input[type=file]').files[0]; var reader = new filereader(); reader.onloadend = function() { preview.src = reader.result; } if (file) { reader.readasdataurl(file); } else { preview.src = ""; } } <input type="file" onchange="previewfile()"> <br> <img src="" height="200" alt="image preview...">
Comments
Post a Comment