HTML input tag file handling -


in code pdf reader pdf-js there input tag let user upload input file

 <input id="fileinput" class="fileinput" type="file" oncontextmenu="return false;" style="visibility: hidden; position: fixed; right: 0; top: 0" /> 

this input tag not part of form. once user uploads file, go? code processes file? (i'm asking in general, not specific piece of code.)

"then it's interesting. code doesn't have server side"

no, doesn't.

pdf.js client side program written javascript. works on javascript side.

it takes file wanna show, , whatever must done converting buffer uint8array renders it.

all processes happen on javascript side. no server side, no file upload.

here article reading local files in javascript

here related part of code in pdf.viewer.js

window.addeventlistener('change', function webviewerchange(evt) {   var files = evt.target.files;   if (!files || files.length === 0)     return;    // read local file uint8array.   var filereader = new filereader();   filereader.onload = function webviewerchangefilereaderonload(evt) {     var buffer = evt.target.result;     var uint8array = new uint8array(buffer);     pdfview.open(uint8array, 0);   };    var file = files[0];   filereader.readasarraybuffer(file);   pdfview.settitleusingurl(file.name);    // url not reflect proper document location - hiding icons.   document.getelementbyid('viewbookmark').setattribute('hidden', 'true');   document.getelementbyid('download').setattribute('hidden', 'true'); }, true); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -