1

how to create a multipart zip file from a folder bigger than my hosting limit?

for example if I have a 15mb folder and my web hosting limit is 8mb per file, is there a way to create the files : zip1.zip (8mb) and zip2.zip (7mb) using php ?

p.s. I dont have permissions to modify the file php.ini .

jdavies
  • 12,784
  • 3
  • 33
  • 33
user962284
  • 670
  • 1
  • 12
  • 29
  • 1
    This is probably going to be close to impossible within the confines of a PHP script. What do you mean by "web hosting limit" exactly? – Pekka Nov 03 '11 at 22:00
  • My free web hosting file limit is 8mb per file, so I cant create a zip file of 15mb – user962284 Nov 03 '11 at 22:02
  • Which file limit exactly? The upload limit, or the file size limit? The latter would be pretty little - I would consider switching web hosts in that case – Pekka Nov 03 '11 at 22:06
  • The filesize limit. but if I change of host, maybe the filesize limit would be bigger, and the 15mb folder, is just an example, what can I do if I have for example a 50mb folder and I want to create a zip file from this folder and I want to avoid the filesize limits and max execution time limit? It is not a good idea create a multipart zip files? – user962284 Nov 03 '11 at 22:13
  • if gz works for you, this may solve it: http://stackoverflow.com/questions/5391304/split-big-files-using-php – Teson Nov 03 '11 at 22:20

2 Answers2

0

use php to walk the dir to add files to zip.

as zip reaches say 4mb, close zip and continue with new zip.

Teson
  • 6,644
  • 8
  • 46
  • 69
  • good idea, should I use scandir() and filesize(), and then create an array according to the file sizes? or do you have a better idea? – user962284 Nov 03 '11 at 22:38
  • @user that won't work, because you don't know what size the files will be in compressed state. You'll just have to pile them on... and you won't be able to have any files that are > 8 MB in compressed form. – Pekka Nov 03 '11 at 23:36
0

This may be doable, but will be insanely complex, especially if you need to split files across multiple zip archives.

I would change hosting providers so you can work with normal big files. A file size limit like that is very unusual.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088