JavaScript file to byte[]

前端 未结 5 1713
野趣味
野趣味 2021-01-12 14:14

Is it possible to read a file in from a path in JavaScript and create a byte[] of that file?

5条回答
  •  醉梦人生
    2021-01-12 14:43

    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.)

提交回复
热议问题