On 14 May, 18:10, Tamir Weiss <tamir.we...@gmail.comwrote:
I'm trying to send a byte array (JPG image) from javascript to a
servlet for processing.
I'm using Base64 to encode the byte array in javascript, and then a
base64 decoder in the servlet to decode it.
The thing is, that even though the String has the same length on both
sides, the decoded byte array is shorter then the original one.
I've tried a couple of different implementation on both sides, with
the same results.
Hi
I don't think you have provided enough information for the question to
be answered.
1. JavaScript does not have a "byte" value, so what do you mean by
"byte array"? Do you mean a JavaScript "Array" of JavaScript
"Number"?
2. How did you manage to load a JPG image into a JavaScript Array in
the first place?
What method did you use? I.e. are you sure that you really did manage
to get a JPG into a JavaScript Array of Numbers without any error?
It is possible to load binary in JavaScript, provided the client
browser has the necessary security permissions. Microsoft have a
number of Active X objects, such as ADODB.Stream and
Scripting.FileSystemObject . It is possible to use
Scripting.FileSystemObject to read binary files, contrary to popular
opinion, but it is a little tricky, and it requires a knowledge of
Windows code pages and the difference between the TextStream.Read and
ReadAll methods.
3. How are you sending the encoded Base64 to the servlet?
4. You may wish to test whether webtoolkit's base64 encoder is
actually working properly.
Julian