javad bat
javad bat

Reputation: 5226

c# MVC Image Upload by ajax

im trying to upload user Avatar for register User and use a image crop plugin to crop it in client side . when i get dataurl and set it to in src attribute it work fine but when i upload it with ajax in c# code i get the string by Request["Avatar"] and get something like this: http://8pic.ir/images/hsiw5swg5alp3xtfvxii.png

but when i trying to convert it to byte in base64 i get following error: http://8pic.ir/images/qvaehyf66rs3rdr9xp91.png

so whats wrong with my code and what can i do ?

Upvotes: 0

Views: 224

Answers (1)

javad bat
javad bat

Reputation: 5226

solved guys i must make some change to base64 string in server side : i add this code and fix the problem

Avatar = Avatar.Replace(" ", "+");
        if (Avatar.Length % 4 != 0)
        {
            Avatar += new string('=', 4 - Avatar.Length % 4);
        }

Upvotes: 1

Related Questions