1

I have implemented image upload page using angularJS.

html binding part and anguler controller part working fine.but problem is when I pass object with uploaded images(64 base string) to server side using Ajax call. it'll give a error something like "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property....."

I have tried adding

<system.web.extensions>
<scripting>
  <webServices>
    <jsonSerialization maxJsonLength="2147483647"/>
  </webServices>
</scripting>

but it doesn't work.

this is my angular service below,

In my angular service "purchaseOrder" is object include with OrderId,Price,ImageUploaded (image as 64 base string)

'use strict';
appForm.factory('CheckoutService', function ($http) {
 function CompleteCheckout(purchaseOrder) {
    return $http({
        method: 'POST',
        url: '/Checkout/CompleteCheckout',
        data: { "objPurchaseOrder": purchaseOrder }
    }).then(function (results) {
        return results.data;
    })
};
return {
      GetCartItems:GetCartItems
}});

1 Answer 1

1

I think first problem is with your approach. You should not upload a file in base64. If you do this then it is going to impact your performance and network usage. Actually when you convert a file in base64 then file size automatically increases to 33%. So if you have a file of 10MB then it will be increase to 13MB.

So instead of uploading file content like this, use multipart implementation. I have give answer about multipart file upload. You can check it here Uploading Excel File in MVC using angularjs. HttpPostedFileBase is empty

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.