Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split big files using PHP

Tags:

file

php

split

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?

like image 422
Mihir Avatar asked Mar 22 '11 12:03

Mihir


Video Answer


1 Answers

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

If on a unix environment, try this...

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

split

Your pieces should be pieces1, pieces2, etc.

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

like image 139
alex Avatar answered Oct 12 '22 12:10

alex