0

I have to send images generated by a javascript function to the server. In order to do it, I store the base64 string of the image in a hidden textbox.

myTextBox.value = 'imagedata';

It works well for small size files (1MB or less).

However, when I try to send large files, the server returns an "Invalid length for a Base-64 char array" error.

The weird part is that I get this error with Chrome but not with Internet Explorer 10.

When I check the value of the string with the debugger, it seems like it is truncated with Chrome.

What causes this problem ? Is there a workaround ?

Thank you.

orel
  • 1,384
  • 10
  • 12
  • 1
    Does this help? [What causing this “Invalid length for a Base-64 char array”](http://stackoverflow.com/questions/858761/what-causing-this-invalid-length-for-a-base-64-char-array) –  May 24 '13 at 15:02
  • Are you POSTing or submitting via GET? – Chris Moschini May 24 '13 at 15:33

2 Answers2

1

You shouldn't be using a single textbox to hold that much content. Textboxes can only hold a limited amount of content. Looks like you're hitting that limit in chrome.

If you really must store that much content, then you'll have to break the content across multiple textboxes.

The max size depends from browser to browser. See here for more information

Community
  • 1
  • 1
bastos.sergio
  • 6,684
  • 4
  • 26
  • 36
0

It could be because QueryString is returning space instead of + (it does that in Chrome, but not I.E.).

Solution:

Decrypt(Request.QueryString["myvar"].Replace(' ', '+'))
live-love
  • 48,840
  • 22
  • 240
  • 204