I'm working on a script that generates several temporary text files on the fly. I'm looking to provide an easy way for the user to download them all at once, so I was thinking about placing them in a temporary Zip archive.

Right now, I'm able to place the contents of each hypothetical text file into a single file, but am not sure how to split it between multiple files. Then I have the Zip issue to worry about.

Is this workable, or would the text and Zip files require separate MIME types?

    Yes; being totally different formats, text and zip files require different MIME types. Otherwise the client is not going to know what to do with them. One is text/plain and the other is application/zip.

    Not sure what the problem with the "splitting into multiple files" is; it's no different from making one file, only you do it more than once. If need be, you can create a temporary directory and put the files in there so that they don't get mixed up with any others. There are functions in PHP for creating directories and temporary files with unique names.

    The whole [man]zip[/man] issue is covered by an extension.

      I've used two different methods of zipping files, and in my opinion, the one included in the phpMyAdmin code is much easier to use.

      It's called zip.lib, and you just need to get it from an installation of phpMyAdmin (at /libraries/zip.lib.php)

        Write a Reply...