views:

128

answers:

1

Is there a Zend Framework method to save content from 3 files (be they dynamically generated or actually exist) and force download as a file?

Similar to this question (which didn't work for me when running from inside a controller so far, despite trying a few different ways):

http://stackoverflow.com/questions/953996/php-zip-3-small-text-files-and-force-download

+1  A: 

The answer is the upvoted one on your other question. Do it from controller, then call exit after you output the zip data so don't you render the view.

Byron Whitlock
I'm getting this error on addFile or addFromString (I've tried both): "Invalid or unitialized Zip object" even though if I do a file_get_contents and echo it out, the data is valid.
joedevon
You have to call $zip->open($filename). with a unique filename (maybe the sessionID of theuser). You can't create a zip in memory.
Byron Whitlock
joedevon
Yes, it is frustrating but i came across the same issue before. It is probably dependent on the php version.
Byron Whitlock
And maybe windows vs *nix. I'd like it to work in both envs. Going to test it presently.
joedevon
That wasn't it. There was a bunch of stuff, I kept throwing different settings, headers, etc and finally got it to work. Whew! Thanks for your help-.
joedevon