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:

fiddle

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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -