PHP 文件上传 - 跟踪使用 AJAX 上传的字节数

发布于 2024-11-03 20:13:09 字数 188 浏览 1 评论 0原文

我试图弄清楚是否有一种方法可以使用 PHP 和/或 Kohana 获取文件上传的进度。我的脚本可以上传图像、视频、zip、exe,无论我真正想要什么。然而,文件越大,用户在没有任何指示的情况下等待的时间就越长。

我希望在这里使用一些 AJAX 来初始化上传,然后报告进度。

PHP 可以做到这一点吗?谁能给我指示从哪里开始寻找。

I'm trying to figure out if there's a way to get the progress of a file upload with PHP and/or Kohana. My script can upload images, videos, zip, exe, whatever I want really. However the larger the file the longer the user has to wait without any indication.

I was hoping to use some AJAX here to initialise the upload and then report back the progress.

Is this possible with PHP... and can anyone give me an indication of where to start looking.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橘味果▽酱 2024-11-10 20:13:09

有一个针对 php 的文件上传进度扩展,请参阅 http://www.ultramegatech.com/blog/2010/10/create-an-upload-progress-bar-with-php-and-jquery/ 了解如何使用 它。

there is a file upload progress extension for php, see http://www.ultramegatech.com/blog/2010/10/create-an-upload-progress-bar-with-php-and-jquery/ for how to use it.

杀お生予夺 2024-11-10 20:13:09

我喜欢使用服务器模块来做这类事情,主要是因为如果我需要做的只是从 URL 获取上传统计信息,那么它会让我作为 Web 开发人员的生活变得更轻松。您的网站无需进行任何更改。

对于 Nginx,有 上传进度 模块,它应该适用于所有最新版本。您可以在 Nginx Wiki 上找到代码示例:http://wiki.nginx.org/HttpUploadProgressModule

对于 Apache还有上传进度。我自己没有使用过它,但它看起来相当简单。

如果您无权访问服务器配置,那么您可能需要退回到纯 flash/javascript 解决方案。为此,我过去在 Uploadify 方面运气不错,但它需要更多的工作,因为你现在必须在单独的请求中上传文件。有人应该也能推荐一个好的 HTML5 上传进度插件。

I like to use a server module to do this sort of thing, mainly because it makes my life as a web developer easier if all I need to do is grab upload statistics from a URL. Nothing has to be changed in your website.

For Nginx there is the Upload Progress module and it should work on all recent releases. You can find code examples on the Nginx Wiki: http://wiki.nginx.org/HttpUploadProgressModule

For Apache there is the Upload Progress too. I haven't used it myself, but it seems fairly straight forward.

If you don't have access to the server configuration, then you might want to fall back onto a pure flash / javascript solution. For this I had good luck with Uploadify in the past, but it requires a bit more work as you now have to upload files in a separate request. Someone should be able to suggest a good HTML5 upload progress plugin too.

守不住的情 2024-11-10 20:13:09

您也可以使用 apache 和 APC 执行此操作示例

you could do this also with apache and APC example

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文