开发者

Read file as its being uploaded

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 r开发者_如何学运维ound this and be able to access the 'byte stream' as the file upload is in progress?


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.)

Check out this question, especially this answer and this one.

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

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.


You will need to have some kind of buffer where new data will be appended and where you read in chunks. Then check if there is new data and read that again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜