0

I'm looking for a best practice method to deserve directory content on download to a user.

Currently I give to users, two techniques : - One by One download using PHP and XSendFile for Apache to better deserve files - A stack for "zipping" a directory temporary (24hours) and download a zip containing a whole directory with the directory hierarchy.

But I'm looking for a better support on a whole directory download in PHP (or other). Do you have any kind of idea to get lower CPU/memory cost and deserve a whole directory faster ?

(The only restriction is to be on server side and the user is navigating through a web browser)

Thank you !

rels
  • 715
  • 2
  • 7
  • 22
  • do you zip the dir for each request, or on a case by case bases? –  Apr 22 '13 at 21:27
  • on case by case, only when requested. But it's a huge cost of memory and time request for user – rels Apr 22 '13 at 21:31
  • so maybe do it in the background, once a day, or what every frequency needed. –  Apr 22 '13 at 21:31
  • it's more live based, doing it once a day would be too restrictive. Currently I give to some users FTP access to their directories but it's really not ideal. – rels Apr 22 '13 at 21:34
  • once an hour? sounds like you have not chosen the best hosting package for this project. If you don't have the cpu\ram for what you need upgrade. –  Apr 22 '13 at 21:35

1 Answers1

0

Gzip is going to give you better compression, on average, than zip, but I would stick with zip because of its portability (Windows only supports this one).

How to [recursively] Zip a directory in PHP?

Which is More Efficient: Zipping With a System Command or Using PHP ZipArchive?

Community
  • 1
  • 1
mbarlocker
  • 1,310
  • 10
  • 16
  • I know how to Zip, it's not the problem I'm doing it at the moment but it's too slow on huge directories. Any other ideas ? – rels Apr 22 '13 at 21:33
  • If your users are Linux users, you could use tar + gzip. If they have 7zip, you could use that. You could also call the zip command directly from the command line (check edited post) – mbarlocker Apr 22 '13 at 21:48
  • Ok so no miracles, going to use it through CLI and use a minimum compression. Thx ! – rels Apr 23 '13 at 15:02