Quantcast

Creating Zip Files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Creating Zip Files

Thomas List

Hello,

I am trying to create a zip file so I can download multiple .pdf files.  The problem I am having is that when I create the Zip file, I do not know where it gets created, and the files are never written to it.  
I am using the pretty standard code :

 if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
             exit("cannot open <$archive_file_name>\n");
          }

to create the file, but I am unable to set the file path because I do not know where the zip file is located.  Does anyone know where the file is created so I can write the files to it and download a zip file with something in it?  

Regards,
Thomas
     
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Creating Zip Files

weierophinney
Administrator
-- Thomas List <[hidden email]> wrote
(on Tuesday, 25 January 2011, 12:55 PM -0500):

> I am trying to create a zip file so I can download multiple .pdf
> files.  The problem I am having is that when I create the Zip file, I
> do not know where it gets created, and the files are never written to
> it.  
> I am using the pretty standard code :
>
>  if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
>              exit("cannot open <$archive_file_name>\n");
>           }
>
> to create the file, but I am unable to set the file path because I do
> not know where the zip file is located.  Does anyone know where the
> file is created so I can write the files to it and download a zip file
> with something in it?  

This question is not related to Zend Framework, but rather to the PHP
language itself. Please ask on the php-general mailing list instead
(list of PHP mailing lists is found here:
http://php.net/mailing-lists.php)

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Creating Zip Files

Nicolas Forgerit
In reply to this post by Thomas List
Hey Thomas,

so you have some .pdf files on your server and want to zip them for
sending them packaged to the requesting client.

The steps would be (assuming you're using PHP's zipping functionalities):
1) Collect the .pdf contents into a temporary zip file. (see PHPs-docs)
2) Set Zend_Controller_Response's MIME-type to "application/zip".
3) Set the Response's content to the temporary zip-file & send it.

The client's browser should now being able to decide what to do with
the server's zip (maybe it just asks for download).

Hope it helps a bit!

Ciao Nico

On Tue, Jan 25, 2011 at 6:55 PM, Thomas List <[hidden email]> wrote:

>
> Hello,
>
> I am trying to create a zip file so I can download multiple .pdf files.  The problem I am having is that when I create the Zip file, I do not know where it gets created, and the files are never written to it.
> I am using the pretty standard code :
>
>  if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE )!==TRUE) {
>             exit("cannot open <$archive_file_name>\n");
>          }
>
> to create the file, but I am unable to set the file path because I do not know where the zip file is located.  Does anyone know where the file is created so I can write the files to it and download a zip file with something in it?
>
> Regards,
> Thomas
>
Loading...