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.

4
  • 1
    possible duplicate of How do I load binary image data using Javascript and XMLHttpRequest? Commented Apr 9, 2013 at 9:05
  • see perhaps stackoverflow.com/questions/80980/… --- 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 Commented Apr 9, 2013 at 9:06
  • @CBroe Please refer to the edit. :) Commented Apr 9, 2013 at 9:46
  • 1
    Can we please remove the duplicate flag if the edit justifies why it is different from the mentioned question? Commented Apr 24, 2013 at 17:58

1 Answer 1

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/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.