在上传文件时读取文件 [英] Read file as its being uploaded

查看:37
本文介绍了在上传文件时读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,您无法访问上传的文件,直到文件完全传输到服务器.

By default you cannot access a file that is uploaded until it has been fully transferred to the server.

解决此问题并能够在文件上传过程中访问字节流"的最佳方法是什么?

What is the best way to get round this and be able to access the 'byte stream' as the file upload is in progress?

推荐答案

我认为您在 PHP 中最接近这一点的是查看各种进度条解决方案,这些解决方案在将文件上传到 PHP 脚本时为您提供进度条.我不知道其中任何一个细节(我一直等到 SWFUpload 可以在 Flash 中执行此操作)但是如果您可以获得上传的进度,那么您很可能也可以自己获得数据块.(更新:基于 APC 的解决方案不能.它似乎只提供上传进度.)

I think the closest you will get to this in PHP is looking at the various progress bar solutions that give you progress bars while doing file uploads to a PHP script. I don't know any of them in detail (I waited until SWFUpload became available to do this in Flash) but if you can get an upload's progress, it's likely you can get the data chunks themselves, too. (Update: the APC based solution can't. It seems to give the upload progress only.)

查看这个问题,尤其是这个答案这个.

这些方法都不是在纯原生 PHP 中运行的,它们都需要 Perl 或 APC 或其他服务器端的东西才能工作.

None of the approaches runs in pure vanilla PHP, they all need Perl or APC or other server-side stuff to work.

最终更新:粗略浏览 Raditha Mega 上传进度barPerl 代码 让我觉得这是你最好的打赌,因为它似乎正在与正在上传的实际文件进行交互.但不能保证.

Final update: A cursory glance at the Raditha Mega Upload progress bar's Perl code makes me think this is your best bet, as it seems to be interacting with the actual file that is being uploaded. No guarantees, though.

这篇关于在上传文件时读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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