Saturday, May 25, 2024
 Popular · Latest · Hot · Upcoming
rated 0 times [  97] [ 2]  / answers: 1 / hits: 22346  / 11 Years ago, wed, january 8, 2014, 12:00:00

How can I access the binary representation with JavaScript from a file uploaded with a file input?:

<input type=file name=file>

I can access the details of the uploaded file successfully with:

// 2013-10-19 15.10.59.jpg

// 774016

// image/jpeg

But not the real representation.

I found this tutorial that makes use of:


However, that method doesn't exists in my browser (Chrome Canary 34.0.1772.0 on OS X 10.9).

More From » jquery



This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

It suggests:

Note: This method is obsolete; you should use the FileReader method readAsBinaryString() or readAsArrayBuffer() instead.

However, FileReader has several other read functions that might be more appropriate, like readAsDataURL() which lets you immediately use the file in web context (e.g as <img> src attribute), see the method listing for all options.

// Retrieve the first (and only, unless using the `multiple` attribute) File from the FileList object
const f = document.getElementById("photo").files[0];

if (f) {
const reader = new FileReader();
reader.onload = function(evt) {
const metadata = `name: ${}, type: ${f.type}, size: ${f.size}, contents:`;
const contents =;
console.log(metadata, contents);

[#73307] Tuesday, January 7, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 421
Total Questions: 132
Total Answers: 102

Location: Trinidad and Tobago
Member since Fri, May 8, 2020
4 Years ago