Some minor issues in the code include the naming of the JSON helper, see here,
JSON.stringify() - JavaScript | MDN[
^] — notice the capitalization of
JSON. Another thing that intrigues me, is, why are you stringifying the image? Did you intent to convert to base64?
How to convert image into base64 string using javascript - Stack Overflow[
^].
Since you wanted to do this using JavaScript (Ajax), there is a much simpler and easier way to handle this... Where you can submit files directly without having to mess up with the base 64. You need to check what
enctype
does your form is currently set to; it must be
multipart/form-data
. That is the only tricky part in this entire domain. Once that is done, you can even capture the file using,
Request.Files
collection.
I wrote a complete article with the sample code that you can use for this, please see:
Uploading the Files – HTML5 and jQuery Way![
^]