Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use IO::Compress::Zip qw(:all);
- my @files = ('example.gif', 'example1.png', 'example2.jpg', 'example3.avi', 'example4.mov');
- my $path = "/home/********/**********";
- print "Content-Type:application/zipn";
- print "Content-Disposition: attachment; filename="filename.zip"nn";
- my $z;
- foreach my $file (@files) {
- if ($z) {
- $z->newStream(Name => $file, Method => ZIP_CM_STORE);
- } else {
- $z = new IO::Compress::Zip "-", Name => $file, Method => ZIP_CM_STORE;
- }
- open(FILE, "<", "$path/$file");
- binmode FILE;
- my ($buf, $data, $n);
- while (($n = read FILE,$data, 1024) != 0) {
- $z->print($data);
- }
- close(FILE);
- }
- $z->close;
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement