Forgive me if this question is too stupid or already asked, I googled a lot, but I got nothing. I need to transfer an array of bytes to the server using ajax, but it does not work as planned, my current code is below.
var bytes = []; for (var i = 0; i < data.length; ++i) { bytes.push(data.charCodeAt(i)); } $.ajax({ url: '/Home/ImageUpload', dataType: 'json', type: 'POST', data:{ data:bytes}, success: function (response) { alert("hi"); } });
Download Method
[HttpPost] public ActionResult ImageUpload(byte[] data) { ImageModel newImage = new ImageModel(); ImageDL addImage = new ImageDL(); newImage.ImageData = data; addImage.AddImage(newImage); return Json(new { success = true }); }
I know something is wrong with my program, but I can not find it, please help me solve this problem.
user1589906
source share