【发布时间】:2017-05-18 07:48:26
【问题描述】:
我正在编写rest api的代码,其中我在页面“imageTest”上,带有图像和按钮的按钮“onclick事件”将调用函数“foo()”
@RequestMapping(value = "/imageUpload2/", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity profilePicTest(@RequestBody String data) {
System.out.println("imageString length : " + data.length());
System.out.println("imageUpload : " + data);
return new ResponseEntity(null, HttpStatus.OK);
javascript部分
function foo() {
alert('uploading image to imageupload2 url');
var profpic = document.getElementById("profpic");
alert('uploading image1122334455')
jQuery.ajax( {
url: 'http://localhost:8090/EventApp/imageUpload2/',
type: 'POST',
data: { img: profpic },
success: function( response ) {
// response
}
} ); alert('uploading done')
}
如果我可以通过 javascript(使用 base64 之类的编码)上传图像,restcontroller 可以接受该图像字符串进一步转换为 byte[] 数组并插入到 oracle db blob 列中,反之亦然以发送它返回
-----问题部分---- 图像未以字符串形式上传到 json 请任何人帮助我...!
【问题讨论】:
标签: javascript json rest image-uploading oracle12c