[英]How can I send request to the server with JSON data and fileupload from AngularJS client using $resource via JAX-RS(Jersey)?
I want to send a request the request to the server with JSON data and an Image file in a single request via JAX-Rs. 我想通过JAX-R在单个请求中将请求与JSON数据和一个图像文件一起发送到服务器。 Using AngularJS $resource.
使用AngularJS $ resource。
Unfortunately this isn't possible. 不幸的是,这是不可能的。 You can upload an image to the server with AJAX, if you target the very latest browsers by using
XmlHttpRequest2
, but you still won't be able to upload both image data and JSON
in one request. 如果使用
XmlHttpRequest2
定位最新的浏览器,则可以使用AJAX将图像上传到服务器,但是仍然不能在一个请求中同时上传图像数据和JSON
。 Generally this is handled by uploading a file inside an iframe
and then triggering something in your angular app once the upload is complete. 通常,这是通过在
iframe
上传文件,然后在上传完成后触发您的角度应用程序中的内容来解决的。
If you google "angular file upload" there are numerous libraries that can help with this. 如果您用谷歌“角度文件上传”,有很多图书馆可以帮助您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.