javascript - HTML5 - Create dynamically an image from a local path? -
is possible create html image, if have path local file? tried use filereader, mere path not work. how can solve issue?
js
var reader = new filereader(); reader.onload = { $('#myimg').attr('src', e.target.result); }; reader.readasdataurl("file:///c:/users/me/appdata/local/temp/msohtmlclip1/01/clip_image002.jpg ");
this simple tool have made reading files in javascript:
the javascript code is:
var reader = new filereader(); reader.onerror = function(ev) { $('#output').html('=== error reading file ==='); } reader.onload = function(ev) { $('#output').html(ev.target.result); }; reader.readasdataurl(e.target.files[0]);
when select image file present base64 datauri of image.
i recommend not trying select file that's not image, don't know what'll happen.
Comments
Post a Comment