1

As the question states, I'd like some way to read files on the client side using JavaScript (is there any other possible alternative?).

These files(images mostly) are part of the webpage, and so I do not need access to the filesystem.

So basically my question should reduce to, is it possible to open a file in binary mode in JavaScript and read it byte by byte?


There seems to be some confusion as to what I'm trying to achieve. The question How do I load binary image data using Javascript and XMLHttpRequest? deals with the case when the user is actually able make his own requests to the server and set his own mime-types etc.

I wish to create a js function/script that reads the already loaded files on the web-page as binary, for the purposes of meta-data extraction.

Community
  • 1
  • 1
ffledgling
  • 11,502
  • 8
  • 47
  • 69
  • 1
    possible duplicate of [How do I load binary image data using Javascript and XMLHttpRequest?](http://stackoverflow.com/questions/1095102/how-do-i-load-binary-image-data-using-javascript-and-xmlhttprequest) – CBroe Apr 09 '13 at 09:05
  • see perhaps http://stackoverflow.com/questions/80980/creating-modifying-images-in-javascript --- Although the accepted answer was that image processing needed to be done on the server, there may be some interesting libraries mentioned amongst the other answers – Paul Apr 09 '13 at 09:06
  • @CBroe Please refer to the edit. :) – ffledgling Apr 09 '13 at 09:46
  • 1
    Can we please remove the duplicate flag if the edit justifies why it is different from the mentioned question? – ffledgling Apr 24 '13 at 17:58

1 Answers1

0

This might not have existed back when you asked but now with the FileReader API you can load a local file client side only.

API in question - https://developer.mozilla.org/en-US/docs/Web/API/FileReader

A well-written example can be found here https://www.javascripttutorial.net/web-apis/javascript-filereader/

In case the page goes away, here is the same content but from the WBM - http://web.archive.org/web/20220913223745/https://www.javascripttutorial.net/web-apis/javascript-filereader/

David
  • 17,673
  • 10
  • 68
  • 97