Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3661004
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:15:38+00:00 2026-05-19T01:15:38+00:00

I would like to compress a directory using 7-Zip and then download it to

  • 0

I would like to compress a directory using 7-Zip and then download it to a web browser.

However, instead of compressing to a file, then having PHP feed the contents of that file to the browser… I would ideally like to Have 7-Zip write the contents of the new archive to standard output as the archive is being created… While simultaneously having PHP flush its buffer and and send the data to the browser.

You see, the archive I’m creating is quite large. From a user’s perspective, using the normal method, when they click “Download,” the archive is first created and saved to a file (which can take ~ 10 minutes), and only then is the file then fed up by PHP to be downloaded. What I am trying to do is combine both the archive and output steps into one single process.

Does anyone have any input on this?

Here is someone else on SourceForge who is trying to do the same thing…

http://sourceforge.net/projects/p7zip/forums/forum/383043/topic/3828566

=======

Thank you for all help. I am going to close this thread, as I have recently discovered an excellent discussion on this topic already exists on StackOverflow. See:

LAMP: How to create .Zip of large files for the user on the fly, without disk/CPU thrashing

=======

This is the final solution I went with, and it is working fantastic for me. Note that I am using the “InfoZip” program, which you can find for pretty much any platform.

header('Content-Type: application/zip');
header('Content-disposition: attachment; filename="file.zip"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');

passthru("zip -8 -q -r - ./some_directory | cat");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:15:39+00:00Added an answer on May 19, 2026 at 1:15 am

    You could try running 7z using passthru with the -so (write data to stdout) option.

    As long as you are sending download headers and content-type headers for 7zip mime types, I believe it will work.

    Example

    <?php
    $filename = "somefile.7z";
    $contentType = "application/x-7z-compressed";
    header("Content-type: ".$contentType); // tell the browser your sending a 7zip file
    header("Content-Disposition: attachment; filename=\"".$filename."\""); // use 'attachment' to force a download
    passthru('/path/to/7z a -so <fileOrDirToBe7Zipped>');
    ?>
    

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to Compress all my file .js in a same directory in
So there are some folders that I would like to compress into tar.gz file
I am having a problem with the compress apache library . I would like
I would like to compress images (camera/photo library) and then send it to the
I have a string that I would like to compress using GZip before inserting
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
I am using the Django GZip middleware (django.middleware.gzip.GZipMiddleware) to compress content if the browser
I would like to compress all css and js on my Dreamhost site, I
I would like to compress the CSS and JS files on my server to
I have a problem I would like to compress all my javascript, but inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.