javascript - While uploading the HTML file reading the image tag and fetching its dimension in angular js -
here i'm uploading html file. html file contains <img>
tag.
e.g.:
<img src="smiley.gif" alt="smiley face" height="42" width="42">
it should read image tag i.e <img>
, tell respective image tag height , width i.e dimension
https://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-reading-files
this link followed reading content.
// html <input type="file" id="files" name="file" /> // javascript function readblob(start, stop) { var reader = new filereader(); // if use onloadend, need check readystate. reader.onloadend = function (evt) { if (evt.target.readystate == filereader.done) { // done == 2 document.getelementbyid('byte_content').textcontent = evt.target.result; document.getelementbyid('byte_range').textcontent = ['read bytes: ', start + 1, ' - ', stop + 1, ' of ', file.size, ' byte file'].join(''); } }; var blob = file.slice(start, stop + 1); reader.readasbinarystring(blob); } var file = document.getelementbyid('files'); document.queryselector('.readbytesbuttons').addeventlistener('click', function (evt) { if (evt.target.tagname.tolowercase() == 'button') { var startbyte = evt.target.getattribute('data-startbyte'); var endbyte = evt.target.getattribute('data-endbyte'); readblob(startbyte, endbyte); } }, false);
Comments
Post a Comment