使用 PHP 拆分大文件 [英] Split big files using PHP

查看:27
本文介绍了使用 PHP 拆分大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 php 代码中将大文件(具体来说,tar.gz 文件)分成多个部分.这样做的主要原因是 php 在 32 位系统上的 2gb 限制.

I want to split huge files (to be specific, tar.gz files) in multiple part from php code. Main reason to do this is, php's 2gb limit on 32bit system.

所以我想将大文件分成多个部分并单独处理每个部分.

SO I want to split big files in multiple part and process each part seperately.

这可能吗?如果是,如何?

Is this possible? If yes, how?

推荐答案

我的评论被投票了两次,所以也许我的猜测是对的 :P

My comment was voted up twice, so maybe my guess was onto something :P

如果在 unix 环境中,试试这个...

If on a unix environment, try this...

exec('split -d -b 2048m file.tar.gz pieces');

拆分

你的棋子应该是pieces1pieces2

通过在 PHP 中使用 stat() 来获取文件大小,然后进行简单的数学运算,您可以轻松获得结果片段的数量 (int) ($stat['size']/2048*1024*1024)(我认为).

You could get the number of resulting pieces easily by using stat() in PHP to get the file size and then do the simple math (int) ($stat['size'] / 2048*1024*1024) (I think).

这篇关于使用 PHP 拆分大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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