I’ve recently been given a task that involves uploading a zip file, storing it in a database as a blog, and then extracting and presenting the contents of that zip file when the client requests it.
I’ve got two approaches for this task: Using the exec command to execute the zip command native to the Linux OS the web server is running on, or using the ZipArchive class that comes with PHP.
- Which approach uses the least amount of memory?
- Which approach offers the most flexibility? W
- What are the major advantages of one approach
over the other?
exec('zip')is way faster for large/many files. The built-in routines are always slower(due to many library calls & overhead. The systemzipmay have the advantage of using highly optimized routines. As a plus to theexecmethod, is the ease to change output formats fromziptorar, or7ziporbzipetc…