Creating zip files

This is a discussion on Creating zip files within the PHP General forums, part of the PHP Programming Forums category; Hi, I am using the "pclziplibrary" to create a zip archive. Now i have the following error message: ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-08-2008
It flance
 
Posts: n/a
Default Creating zip files

Hi,

I am using the "pclziplibrary" to create a zip archive.
Now i have the following error message:
Error : PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to open archive 'archive.zip' in wb mode

If someone is using the same library please tell me what this error means exactly. I am using the same code in my PC, it is working but not in the real server.

What i am able to do in my pc is writing the archive to the disc. Do you know if there is a way to create the archive just in memory and let the user download it without having to store it in the server?

Thank you




Reply With Quote
  #2 (permalink)  
Old 07-08-2008
Eric Butera
 
Posts: n/a
Default Re: [PHP] Creating zip files

On Tue, Jul 8, 2008 at 3:17 PM, It flance <itmaqurfe@yahoo.com> wrote:
> Hi,
>
> I am using the "pclziplibrary" to create a zip archive.
> Now i have the following error message:
> Error : PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to open archive 'archive.zip' in wb mode
>
> If someone is using the same library please tell me what this error means exactly. I am using the same code in my PC, it is working but not in the real server.
>
> What i am able to do in my pc is writing the archive to the disc. Do you know if there is a way to create the archive just in memory and let the user download it without having to store it in the server?
>
> Thank you
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Has it ever worked on the server? You might need to check permissions
to see if your php script has access to write the zip archive to disc.

If you're using php5 you can use the ZipArchive[1] extension that is
built in now. It is quite fast and easy to use.

[1] http://us2.php.net/manual/en/ref.zip.php
Reply With Quote
  #3 (permalink)  
Old 07-08-2008
Daniel Brown
 
Posts: n/a
Default Re: [PHP] Creating zip files

On Tue, Jul 8, 2008 at 3:17 PM, It flance <itmaqurfe@yahoo.com> wrote:
> Hi,
>
> I am using the "pclziplibrary" to create a zip archive.
> Now i have the following error message:
> Error : PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to open archive 'archive.zip' in wb mode


Does the file `archive.zip` exist where the script is looking for
it, and is it readable?

This has nothing to do with PHP itself. Check with the support
team for that project:

http://www.phpconcept.net/pclzip/index.en.php

--
</Daniel P. Brown>
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.
Reply With Quote
  #4 (permalink)  
Old 07-08-2008
It flance
 
Posts: n/a
Default Re: [PHP] push data directlly to the client(was Creating zip files)

Hi,

Thank you for your answer. Now i figured out how to build the zip archive.
I am using a class that returns the compressed data:

$zipedresult = $zipfile->zipped_file();

This data, i can write it to a file. but i would like to make it downloadable without having to store it in the server. Is that possible?

Thanks


--- On Tue, 7/8/08, Eric Butera <eric.butera@gmail.com> wrote:

> From: Eric Butera <eric.butera@gmail.com>
> Subject: Re: [php] Creating zip files
> To: itmaqurfe@yahoo.com
> Cc: php-general@lists.php.net
> Date: Tuesday, July 8, 2008, 7:22 PM
> On Tue, Jul 8, 2008 at 3:17 PM, It flance
> <itmaqurfe@yahoo.com> wrote:
> > Hi,
> >
> > I am using the "pclziplibrary" to create a

> zip archive.
> > Now i have the following error message:
> > Error : PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to

> open archive 'archive.zip' in wb mode
> >
> > If someone is using the same library please tell me

> what this error means exactly. I am using the same code in
> my PC, it is working but not in the real server.
> >
> > What i am able to do in my pc is writing the archive

> to the disc. Do you know if there is a way to create the
> archive just in memory and let the user download it without
> having to store it in the server?
> >
> > Thank you
> >
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >

>
> Has it ever worked on the server? You might need to check
> permissions
> to see if your php script has access to write the zip
> archive to disc.
>
> If you're using php5 you can use the ZipArchive[1]
> extension that is
> built in now. It is quite fast and easy to use.
>
> [1] http://us2.php.net/manual/en/ref.zip.php





Reply With Quote
  #5 (permalink)  
Old 07-08-2008
Shawn McKenzie
 
Posts: n/a
Default Re: [PHP] push data directlly to the client(was Creating zip files)

It flance wrote:
> Hi,
>
> Thank you for your answer. Now i figured out how to build the zip archive.
> I am using a class that returns the compressed data:
>
> $zipedresult = $zipfile->zipped_file();
>
> This data, i can write it to a file. but i would like to make it downloadable without having to store it in the server. Is that possible?
>
> Thanks


Yes. Now that you have the zip file contents, send the correct headers
to the browser for content-type and disposition, etc using header(),
then echo $zipedresult. I can never remember the header to send I have
to look it up most times.

-Shawn
Reply With Quote
  #6 (permalink)  
Old 07-08-2008
Shawn McKenzie
 
Posts: n/a
Default Re: [PHP] push data directlly to the client(was Creating zip files)

Shawn McKenzie wrote:
> It flance wrote:
>> Hi,
>>
>> Thank you for your answer. Now i figured out how to build the zip
>> archive.
>> I am using a class that returns the compressed data:
>>
>> $zipedresult = $zipfile->zipped_file();
>>
>> This data, i can write it to a file. but i would like to make it
>> downloadable without having to store it in the server. Is that possible?
>>
>> Thanks

>
> Yes. Now that you have the zip file contents, send the correct headers
> to the browser for content-type and disposition, etc using header(),
> then echo $zipedresult. I can never remember the header to send I have
> to look it up most times.
>
> -Shawn


So I searched for it again but didn't test:

$zipedresult = $zipfile->zipped_file();

header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=SomeFileName.zip");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");

echo $zipedresult;
Reply With Quote
  #7 (permalink)  
Old 07-09-2008
Pavel
 
Posts: n/a
Default Re: [PHP] Creating zip files

В сообщении от Wednesday 09 July 2008 01:22:32 Eric Butera написал(а):

> [1] http://us2.php.net/manual/en/ref.zip.php

Thank you for this link!


--
===============
С уважением, Манылов Павел aka [R-k]
icq: 949-388-0
mailto:rap-kasta@mail.ru
===============
А ещё говорят так:
*одился сам - помоги другому.
-- Неизвестный автор
[fortune]
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:28 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0