Example of creating a zip file with ASP and csASPZipFile.

These pages show an example of using csASPZipFile to dynamically create a zip file on the server and stream it to the browser. The user can select files from a list and these will be collected and compressed into a zip archive. This example can be downloaded. You will need the csASPZipFile trial component registered on your server as well as having the scripts that are available below.

Download the trial csASPZipFile component - cszft.zip (437 KB)

Download the demo scripts - zipdemo1.zip (4 KB)

The files available for download are the entire contents of a directory and they are selected by checking the boxes. They are only one line text files and tiny bitmaps and are completely irrelevant, but it is the idea that matters.

Select the files for download

1.txt
2.txt
3.txt
4.txt
5.txt
6.txt
7.txt
8.txt
9.txt
blue.bmp
green.bmp
red.bmp
  

This example has been kept simple to make it easier to follow the code. Click here for a description of how it all works. The sample files also contains a description in the Read Me file.

This approach leaves the form in the browser after the file has been downloaded and that is not always desireable. It is not possible to put a redirection in the download script because it is producing binary output (the zip file) and HTML cannot follow this so some other method must be used to display a different page at the end of the process. One possibility is to use Javascript to open a new window. Click here for a demo showing a way of doing this.

Another possibility not shown here would be to save the zip file temporarily and link to it. The Session ID could be used as the file name and the file could be deleted automatically when the session ended.