2011-11-24 12:29 阅读 20


I would like to implement feature like GMail's "get all attachments as zipped file".

Is there a way to select multiple files on server, zip them and on-the-fly pass-through to browser? (something similar to PHP's function readfile used for attachments streaming)


It seems you misunderstood my intentions, all given examples require to create and close archive before its being sent, I want to stream while archive is created.

Something like unix command (from zip manual): zip -r - . | dd of=/dev/nrst0 obs=16k


I have tons of ~2MB files (> 100) to serve, waiting for creation of tmp zip file forces to implement queuing mechanisms and takes storage space... If it can be done through stream/pipe directly to browser, why I should write tmp zip in filesyetm?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dsgwdigu84950 dsgwdigu84950 2011-11-24 12:36

    Have a look at ZipStream-PHP library - it claims to do what you need.

    点赞 评论 复制链接分享
  • duanchangnie7996 duanchangnie7996 2011-11-24 12:56

    Your PHP host could happen to have the zip extension installed. If so, you should use it. (performance reasons)

    Otherwise, for zip archiving, a good library with no dependencies is PclZip.

    There obviously was a PEAR library for it, but is now deprecated and focus has been moved over to the PECL (binary) extension I already mentioned. (the whole PEAR ecosystem is gradually rotting down, anyway)

    点赞 评论 复制链接分享