RE: [PHP] PHP Zip Question

2006-11-07 Thread Matt Street
Richard,

Thank you for your post and the link to your rant. Indeed I am a PHP newbie
and have fallen into the advice I have been given through google. . .

I have added an exit and probably owe you a donut as I had to remove a
couple of echo's from my code! However, the good news after all of this is
that my code is now working and I can finish off my tests.

Thanks again

Matt

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: 06 November 2006 21:02
To: Matt Street
Cc: 'php-general@lists.php.net'
Subject: RE: [PHP] PHP Zip Question

On Mon, November 6, 2006 6:28 am, Matt Street wrote:
 Thanks for the response, I decided that it was easier to unpack the
 zip
 during the upload process and then delete the zip. I can then indicate
 which files I want to zip up and this works (opening the zip on the
 server), but, and it's a big but, when the zip is downloaded to the
 users machine it is being corrupted!

 To force the download I use:

 header('Content-type: application/zip');
 header('Content-Disposition:  attachment; filename='.$tutorzipfile);
 readfile($filename);

 Which correctly gives me:

 Content-Type: application/zip
 Content-disposition: attachment; filename=tutorzipfile.zip

 when viewing the LiveHTTPHeaders extension in firefox.

Rant #37
http://richardlynch.blogspot.com/

 However, when I view the zip file that is downloaded to my machine, in
 Textpad, php has appended the directory information of the files I'm
 zipping up onto the front of the zip file, so it no longer starts
 PK!!!

PHP didn't do it.

Your zip routines may have done it.

Your code may have done it.

But PHP is not, no its own, just outputting the directory info for no
real reason.

Put an exit right before you readfile() and the headers.

You may need to move the headers down below all the code that
calculates what's getting zipped up and all that...

Dollars to donuts says you've left behind a debugging:
echo pwd();
or something similar.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] PHP Zip Question

2006-11-06 Thread Matt Street
Thanks for the response, I decided that it was easier to unpack the zip 
during the upload process and then delete the zip. I can then indicate 
which files I want to zip up and this works (opening the zip on the 
server), but, and it's a big but, when the zip is downloaded to the 
users machine it is being corrupted! 

To force the download I use: 

header('Content-type: application/zip'); 
header('Content-Disposition:  attachment; filename='.$tutorzipfile); 
readfile($filename); 

Which correctly gives me: 

Content-Type: application/zip 
Content-disposition: attachment; filename=tutorzipfile.zip 

when viewing the LiveHTTPHeaders extension in firefox. 

However, when I view the zip file that is downloaded to my machine, in 
Textpad, php has appended the directory information of the files I'm 
zipping up onto the front of the zip file, so it no longer starts PK!!! 

Anyone any ideas??? 

Thanks in advance 

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] PHP Zip Question

2006-11-06 Thread Richard Lynch
On Mon, November 6, 2006 6:28 am, Matt Street wrote:
 Thanks for the response, I decided that it was easier to unpack the
 zip
 during the upload process and then delete the zip. I can then indicate
 which files I want to zip up and this works (opening the zip on the
 server), but, and it's a big but, when the zip is downloaded to the
 users machine it is being corrupted!

 To force the download I use:

 header('Content-type: application/zip');
 header('Content-Disposition:  attachment; filename='.$tutorzipfile);
 readfile($filename);

 Which correctly gives me:

 Content-Type: application/zip
 Content-disposition: attachment; filename=tutorzipfile.zip

 when viewing the LiveHTTPHeaders extension in firefox.

Rant #37
http://richardlynch.blogspot.com/

 However, when I view the zip file that is downloaded to my machine, in
 Textpad, php has appended the directory information of the files I'm
 zipping up onto the front of the zip file, so it no longer starts
 PK!!!

PHP didn't do it.

Your zip routines may have done it.

Your code may have done it.

But PHP is not, no its own, just outputting the directory info for no
real reason.

Put an exit right before you readfile() and the headers.

You may need to move the headers down below all the code that
calculates what's getting zipped up and all that...

Dollars to donuts says you've left behind a debugging:
echo pwd();
or something similar.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP Zip Question

2006-10-26 Thread Richard Lynch
Post a link to your on-line application.

Also, use LiveHTTPHeaders and such to make sure you are getting what
you think you are getting.

And use vi or TextPad or whatever on your desktop to open up the .zip
file and see what's in there.

If it starts with:
ERROR: PHP error blah blah blah
then you've got a pretty good idea why it's not a valid zip file :-)

On Tue, October 24, 2006 6:39 am, Matt Street wrote:
 Dear all,

 I am trying to create a zipping mechanism that allows the user to
 select a
 number of files from a list; these files are then zipped and
 downloaded to
 the user's machine. I presently have:

 $zip = new ZipArchive();
 $filename = $zipfinalpath.tutor/zipfiles/.$tutorzipfile;

 if ($zip-open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
   exit(cannot open $filename \n);
 }
 else {
   $loopCount = 0;
   foreach ($filelisttozip as $i = $fileValue) {
   //the
   $zip-addFile($fileValue,$filenamelisttozip[$loopCount]);
   $loopCount ++;
   }
 }

 $zip-close();

 In my test sample of files I have the following file types:

 .doc
 .zip
 .jpg
 .doc

 And the zip mechanism works when I ask for all or omit any of the
 files from
 the list, except when I omit the zip file! E.g.

 1. Asking for all works
 2. Asking for .zip,.jpg,.doc works
 3. Asking for .doc,.zip works
 4. Asking for .doc,.jpg,.doc doesn't work - 7-zip tells me that the
 file is
 not support archive and windows tells me the Compressed(folder) is
 invalid
 or corrupted!

 I have used different zip files to make sure that it's not the file,
 but all
 to no avail. . .but if I add:

 $zip = zip_open($filename);
 while ($zip_entry = zip_read($zip)) {
   $file = basename(zip_entry_name($zip_entry));

   echo 'a'.$file.'br';
 }
 zip_close($zip);

 to the bottom of my page it correctly displays, on screen, the 3 files
 I
 expect to be in the zip file.

 Any help would be very gratefully received as this is driving me
 mad!!!

 Matt

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php