I am using the Zip Archive Class to create zip files of documents related to the outcome of a specific "configuration" where the user creates a mockup of a system he may choose to buy from the company and based on the users choices, specific support documents can be asked to be downloaded. The names of the documents themselves do not reveal their content. For example, a product brochure document might be ABC-XYZ-00987.pdf. To make the contents of the created zip file meaningful to the user, we want to create a subfolder named like 43210files where 43210 is the unique visitor ID of the user running this session. Within the subfolder, we want to create other sub folders, like Brochure, IO Manual, Summary, Product Drawing, etc. Then the exact required document will be copied into that sub sub folder. So, for example, we will have this subfolder under the directory level of the executing download program creating the zip file: downloads/43210files/Brochure/<actual file name>. Typically there will be 3 to 8 files per download.
What we want the zip file to look like is to include the sub sub directory name (like Brochure/file_name but NOT the "downloads/43210files.
What is the best way to do this? Note, we do not HAVE to use the php class Zip Archive if there is a different or better way.
Thank you
1) A logged in user selects a product/item can be one or multiple
2) Grab selected files to be downloaded, create one zip file made up of those files
The easy part is zipping up the file. If you have a class like https://github.com/alexcorvi/php-zip it is a matter of using their example and making it your own. This seems like the easy part.
Open in new window
How are the files that can potentially be downloaded associated with the items the user is picking out? By database? some other means? Is this one of the parts you need help with?
Does the final zip file need to be saved on the server for a specified length of time for anybody that has the link to download? Or would it be better to keep the files outside of the public www as well as the generated zip file. Then once the zip is created, stream it down to the user. Once they download it, there is no link to keep downloading it by accident. You can still create a link like <a class="download" id="downloadlink43210" href="43210 ">43210</a> and via an ajax request stream the file down. That way you are not keeping files on the public www.