-1

I have not much experience with php at all, but basically all I'm after is a button on a page, let's say I have a form markup like this:

<form name="downloader" action="download.php" method="get">
    <input type="text" value="test" name="test"/>
    <button type="submit">DOWNLOAD</button>
</form>

What I need to do is compile say 3 files, lets say their in folders like this:

root ==>
    css ==>
        grid.css
        main.css
    js  ==>
        main.js

What If I wanted to just get the two css files, and the whole javascript folder, zip them up and download them for the user.

The reason why these aren't already zipped up and ready to go, is later on, the form will be editing variables inside the main.js file.

How can I do this?

Shannon Hochkins
  • 11,763
  • 15
  • 62
  • 95
  • You seem to misuse terms that usually have a very precise meaning in the field of programming, it makes your question hard to understand. I suppose you do not want to *compile* your files (compilation is the process of converting source code into byte code), and you do not want to *download the zip for the user* (downloading is the process of copying a remote file to a local machine -- I suppose you meant "allow the user to download it"). If I understand it right, [this question has already been adressed before](http://stackoverflow.com/questions/1754352/download-multiple-files-as-zip-in-php). – RandomSeed Jul 05 '13 at 12:20
  • Actually, I used the word compile in the context of assembling files together, which is perfectly fine. And the other, is a simple miss type, anyway, thanks for the link. – Shannon Hochkins Jul 05 '13 at 12:32
  • Additionally, the link you provided doesn't explain how to add a whole folder. Sometimes, I fear that people only comment on posts just to correct every little thing about a post and it's not what stack overflow is about. It should be about help yes, but not to the extent of belittling. – Shannon Hochkins Jul 05 '13 at 12:41
  • A linguist would 100% agree with you. However, I was only pointing out that this term was misleading in this context. – RandomSeed Jul 05 '13 at 12:43

1 Answers1

0

This question explains how to add individual files to a Zip archive.

Use ZipArchive::addEmptyDir() to recreate your directory tree in the archive.

You can provide ZipArchive::addFile() with a second parameter, the target path in the archive.

Or you can use this.

Community
  • 1
  • 1
RandomSeed
  • 29,301
  • 6
  • 52
  • 87