文件上传进度如何报道? [英] How is the file uploading progress reported?

查看:110
本文介绍了文件上传进度如何报道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力实现一个Ajax风格的文件上传。我想知道什么,我们必须做的报告上传进度。我想在我的asp.net页面来实现这一点。

I have been trying to implement an ajax-style file upload. I was wondering what we must do to report the uploading progress. I am trying to implement this in my asp.net web page.

我理解,我们可以上传文件,Ajax风格的,在网页上的机制。我一直在谷歌上搜索了很多关于如何显示一个进度条,但我没有看到合适的解释。但我认识到,我们必须从服务器端的一些如何进行管理。 (参见<一个href=\"http://stackoverflow.com/questions/1298565/file-upload-progress\">http://stackoverflow.com/questions/1298565/file-upload-progress)

I understand the mechanism by which we can upload a file, ajax-style, on a web page. I have been googling a lot about how to show a progress bar, but I don't see proper explanations. But I've come to understand that we have to manage this from the server-side some how. (cf http://stackoverflow.com/questions/1298565/file-upload-progress)

任何想法/ code将AP preciated。感谢名单提前。

Any ideas/code would be appreciated. Thanx in advance.

推荐答案

我不知道你为什么要推出自己的,因为有使用Ajax,Flash游戏,Silverlight的一些上传控件等。尽管如此,概念是所有关于在查询进展,并返回当前状态。 这家伙通过同样的流程去并展示了如何他建成使用jQuery 的一个组成部分。

I'm not sure why you want to roll your own, as there are a number of upload controls using Ajax, Flash, Silverlight, etc. Nonetheless, the concept is all about querying for progress and returning the current state. This guy went through the same process and shows how he built a component using jQuery.

显示进度需要您的客户端从服务器获得反馈。这意味着重复查询到你的服务器来获得进展。显示使用该信息客户端上的进度。

Displaying progress requires your client getting feedback from your server. This means repetitive queries to your server to get progress. Display the progress on your client using that information.

在你的服务器,你必须不仅接受入站文件上传,但也与总进度做出回应。如果你得到Content-Length头沿请求通过这很容易;问题就出在,你将不能够依靠其信息。有处理这一策略,但它需要你有code接受为你将要读入位上传的文件。

On your server, you have to not only accept the inbound file upload but also respond with the aggregate progress. It's easy if you get the Content-Length header passed along in the request; the problem lies in that you won't be able to rely on having that information. There are strategies for dealing with this, but it requires you to have code that accepts the uploaded file as you're going to have to read the inbound bits.

在这一点上,你还有其他的事情要关心,远远超出了进度条的范围,如大文件上传过程中的Web服务器的处理(外的过程是更有害您的服务器。)

At this point, you have other things to care about that are well beyond the scope of a progress bar, such as dealing with large file uploads in-process of your web server (out-of-process is much less detrimental to your server.)

由于的复杂性参与其中,我会鼓励你找到一个现有的组件,而不是创建自己的。

Because of the complexities involved, I would encourage you to find an existing component instead of creating your own.

这篇关于文件上传进度如何报道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆