如果ImgData包含数据URI格式为base64的图像,则将以下行添加到Imgvalue以将其转换为ImgData:
var imgData = JSON.stringify(ImgValue);
我建议您使用AJAX通过OData发布图像,如以下代码所示:
OData.request ({ requestUri:"http://test.test1.net:8081/sap/opu/odata/sap/ SALES_VRS/DailySalesSet", method: "GET", headers: { -Requested-With": "XMLHttpRequest", "Content-Type": "application/atom+xml", "DataServiceVersion": "2.0", "X-CSRF-Token":"Fetch" } }, function (data, response) { header_xcsrf_token = response.headers['x-csrf-token']; csrftoken = header_xcsrf_token; $.ajax({ url: 'http://test.test1.net:8081/sap/opu/odata/sap/ZPVSYSTEM_SRV/PromoImagesSet/', //dataType:'json', data: imgData, //数据:图片 type: 'POST', headers: { "X-Requested-With": "XMLHttpRequest", "Content-Type": "image/png", "DataServiceVersion": "2.0", /*"Accept": "application/atom+xml,application/atomsvc+xml,application/xml", */ "X-CSRF-Token": csrftoken, "slug": slug, }, success: function(data) { debugger; console.log(data); }, error: function(data) { debugger; console.log(data); } });