Hi guys,

thanks to Jim, I made it :o) Here's the source I'm using for testing now... it works. I just need to make it less vulnerable ;o)

----- SNIP -----
<?
$nr  = $_GET['nr'];
if(eregi("../", $nr)) {
die("Hier wird nicht rumgehackt");
}
$directory = '_kfz_images/'.$nr.'/full/';
$dir = opendir($directory);
$i = 1;
while($file = readdir($dir)) {
$dest = "temp/Auto-Deppe-".$nr."_".$i.".jpg";
if(eregi("jpg", $file)) {
 copy($directory.$file, $dest);
 $i++;
}
}
$now = time();
header("Content-Type: application/force-download");
header('Content-Disposition: attachment; filename="Auto-Deppe-'.$now.'_Download.zip"');
exec("zip ".$now."_archive.zip temp/* 2>&1", $output);
readfile($now."_archive.zip");
$tempdir = opendir("temp");
while($tempfile = readdir($tempdir)) {
if(eregi("jpg", $tempfile)) {
 unlink("temp/".$tempfile);
}
}
?>
----- SNAP -----
So I am copying the files to a temp dir, and then zip em up, delete them afterwards. I copy them to the dir so I wouldn't have the whole /kfz_images/number/full/ structure in the zip).

Aaaanyhow, it works, it does work fast enough, and I am happy :o)

Thanks a bunch, guys, and have a great day!

This is Christian Haensel live from Extertal, Germany. Back to you.

-:oD)=


----- Original Message ----- From: "Tijnema" <[EMAIL PROTECTED]>
To: "Chris" <[EMAIL PROTECTED]>
Cc: "Auto-Deppe, C. Haensel" <[EMAIL PROTECTED]>; <php-general@lists.php.net>
Sent: Friday, June 01, 2007 9:27 AM
Subject: Re: [PHP] ZIP it :o)


On 6/1/07, Chris <[EMAIL PROTECTED]> wrote:
Auto-Deppe, C. Haensel wrote:
> Morning guys,
>
> I have been trying to find an easy to use way to zip an archive on a > linux
> box running PHP5. Now I've tried the zip-lib.php and others, but they
> always
> throw an error msg.... But that is not the question.
>
> I am looking to use exec("zip archive.zip $directory");  $directory has
> been
> tried with both full path and relative path ... but that doesn't work. > I
> don't get an error, it just doesn't create the zip-file...
>
> So, after a day of Google-ing and trying, I thought I might ask you for
> help.
>
> Cheers for any answers and hints.

http://pear.php.net/package/Archive_Zip and/or
http://pear.php.net/package/File_Archive

and please create a *new* message instead of replying to an existing one
and changing the topic. It screws up message threading (in email clients
and in the archives).

Not in gmail :)

I had same problem lately, wanted also to create zip files from PHP, i
tried various build in functions, but i ended up with the exec way.
It has been said before, but PHP probably doesn't have the right
permissions to write the .zip file, so i would recommend you to write
to /tmp first.

Tijnema




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

Reply via email to