AngularJS 中的 $http 上传文件进度 [英] $http upload file progress in AngularJS
问题描述
如何从上传图像的 AngularJS $http POST 请求中获取进度"事件?是否可以在客户端执行此操作,或者我是否需要服务器在接收数据时报告进度?
How can I get a 'progress' event from my AngularJS $http POST request that is uploading an image? Is it possible to do this client-side, or do I need the server to report the progress as it receives the data?
推荐答案
我认为 $http.post() 不能用于此.
I don't think $http.post() can be used for this.
至于客户端,它应该适用于 HTML5 浏览器,但您可能需要创建自己的 XMLHttpRequest 对象和 onprogress
侦听器.参见 AngularJS:跟踪同时上传的每个文件的状态 想法.
As for client-side, it should work with an HTML5 browser, but you'll probably have to create your own XMLHttpRequest object and onprogress
listener. See AngularJS: tracking status of each file being uploaded simultaneously for ideas.
这篇关于AngularJS 中的 $http 上传文件进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!