Is it possible to read a file in from a path in JavaScript and create a byte[] of that file?
No. JavaScript is purposely designed to have very minimal file IO (think cookies) because allowing it to access arbitrary files (local and remote) would be a massive security risk.
There are two forms of JavaScript: client-side and server-side. In client-side JavaScript it is not possible, while in server-side JavaScript, it is possible. So it depends on whether you are using client-side or server-side JavaScript.
That said, client-side JavaScript is much more common and if you were using server-side JavaScript, you would probably know the answer to your question. So I'm going to go out on a limb and say that no, it is not possible to read in from a path in JavaScript and create a byte[] from that file.
(Also, it's unclear what you mean by a byte[]; that's not a common notation when using JavaScript. Are you sure you aren't talking about Java? Java is completely different from JavaScript: in Java byte[] is a more common notation.)
File I/O in Javascript is considered a serious security risk:
http://forums.devshed.com/javascript-development-115/file-i-o-with-javascript-10376.html
Yes, you can — in Firefox, anyway. Other browsers may or may not choose to allow it in the future.
Make a file upload field for the user to pick the file, and read it through the input.files list. eg. document.getElementById('myuploadfield').files[0].getAsBinary()
. This puts each byte in a single character of a JavaScript String, which is about as close to a byte[] as you're going to get.
This is quite a specialized interface and probably Not The Right Thing — heed the other replies, because it's very possible you are trying to do something in a inappropriate way. Difficult to tell without context.