上传进度指示器没有特殊的ajax上传器?
我有一个 Rails 应用程序,可以上传文件(大文件〜300mb)。有没有一种方法可以在不使用特殊的 htnl5 上传器或安装 nginx 服务器模块的情况下实现进度指示器?只使用标准文件上传字段?
提前致谢
i have a rails app which uploads a file (big files ~300mb). is there a way to implement a progress indicator without using a special htnl5 uploader or install the nginx server module? just using the standard file upload field?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只知道 JS/AJAX,其中 DOM 在成功上传回调时更新。
或者,您可以考虑设置express/Node.js来处理流式上传并使用AJAX来更新DOM(在这种情况下,您的Node.js服务将与Rails分离运行 - 您将通过JSON从Rails连接到它)
I'm only aware of JS/AJAX where the DOM is updated on successful upload callback.
Alternatively, you could look into setting up express/Node.js to handle streamed uploading and use AJAX to update DOM (in this case your Node.js service would run decoupled from Rails - you'd be connecting to it from Rails via JSON)
如果您正在执行纯 AJAX,我建议您进行一个特殊的调用,它可能会返回当前的上传状态 (/upload/status/upload_id)。例如,您可以有一个计时器,每 2 秒询问一次进度。
在服务器端,您有一个处理上传并能够报告进度的线程。
If you are doing that pure AJAX, I would suggest you have a special call which might return you current status of upload (/upload/status/upload_id). You can have a timer and ask for progress every 2 seconds for instance.
On a server side you have a thread that handles upload and able to report a progress.