Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想通过 JAX-Rs 在单个请求中向服务器发送一个请求,该请求包含 JSON 数据和一个图像文件。使用 AngularJS $resource。
不幸的是,这是不可能的。您可以使用 AJAX 将图像上传到服务器,如果您使用 定位到最新的浏览器XmlHttpRequest2,但您仍然无法同时上传图像数据和JSON一个请求。通常,这是通过在一个文件中上传一个文件来处理的iframe,然后在上传完成后在你的 Angular 应用程序中触发一些东西。
XmlHttpRequest2
JSON
iframe
如果你用谷歌搜索“角度文件上传”,有很多库可以帮助你解决这个问题。