問題描述
我想從 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 拆分大文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!