orel
orel

Reputation: 1469

Invalid length for a Base-64 char array Exception under Chrome

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.

Upvotes: 0

Views: 666

Answers (2)

live-love
live-love

Reputation: 52386

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(' ', '+'))

Upvotes: 0

bastos.sergio
bastos.sergio

Reputation: 6764

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

Upvotes: 1

Related Questions