首页 > 解决方案 > 如何将复杂json对象中的图像从js上传到asp?

问题描述

我可以将带有formdata的图像从js发送到asp web api但是当图像作为属性在对象中时我不知道如何使用json对象

我在asp中有这些类:

     public class SessionExam
        {
            public int id { get; set; }
            public decimal max { get; set; }
            public decimal min { get; set; }
            public int duration { get; set; }
            public List<SessionExamQuestion> questions { get; set; }
        }

     public class SessionExamQuestion
        {
            public int id { get; set; }
            public string text { get; set; }
            public decimal mark { get; set; }
            public List<SessionExamQuestionOption> options { get; set; }
            public byte[] image { get; set; }
        }

     public class SessionExamQuestionOption
        {
            public int id { get; set; }
            public string text { get; set; }
            public bool isRight { get; set; }
        }

SessionExamQuestion 类具有作为字节数组的图像属性

如何使用 ajax 将图像从 javascript 发送到 asp web api?

我曾经将图像作为多部分发送到 asp

提前谢谢你们

标签: javascriptasp.netajaximagefile-upload

解决方案


推荐阅读