Split big files using PHP(使用 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');
拆分
你的棋子应该是pieces1
、pieces2
等
通过在 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 拆分大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 PHP 拆分大文件


基础教程推荐
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- 使用 PDO 转义列名 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01