Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. use IO::Compress::Zip qw(:all);
  2.  
  3. my @files = ('example.gif', 'example1.png', 'example2.jpg', 'example3.avi', 'example4.mov');
  4.  
  5. my $path = "/home/********/**********";
  6.  
  7. print "Content-Type:application/zipn";
  8. print "Content-Disposition: attachment; filename="filename.zip"nn";
  9.  
  10. my $z;
  11.  
  12. foreach my $file (@files) {
  13. if ($z) {
  14. $z->newStream(Name => $file, Method => ZIP_CM_STORE);
  15. } else {
  16. $z = new IO::Compress::Zip "-", Name => $file, Method => ZIP_CM_STORE;
  17. }
  18.  
  19. open(FILE, "<", "$path/$file");
  20. binmode FILE;
  21.  
  22. my ($buf, $data, $n);
  23.  
  24. while (($n = read FILE,$data, 1024) != 0) {
  25. $z->print($data);
  26. }
  27.  
  28. close(FILE);
  29. }
  30.  
  31. $z->close;
  32.  
  33. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement