valentinaCom Posted October 1, 2014 Share Posted October 1, 2014 hi I'm trying to upload a file from local disk to my project: js:function showMyImage(fileInput) { var files = fileInput.files; for (var i = 0; i < files.length; i++) { var file = files; var imageType = /image.*/; if (!file.type.match(imageType)) { continue; } var img= document.getElementById("thumbnil"); img.file = file; var reader = new FileReader(); reader.onload = (function(aImg) { return function(e) { aImg.src = e.target.result; }; })(img); reader.readAsDataURL(file); console.log(reader) }} html:<input type="file" accept="image/*" onchange="showMyImage(this)" /> <br/> <img id="thumbnil" style="" src="" alt="image"/> It's work. however I am trying to add the file (image) as a phaser image in the game. There is a way to do it? thank you! Link to comment Share on other sites More sharing options...
xerver Posted October 1, 2014 Share Posted October 1, 2014 Phaser's loader can load data urls, just pass e.target.result to the phaser loader instead of into an img tag's source. Link to comment Share on other sites More sharing options...
Recommended Posts