#!/usr/bin/perl ############################################################################### # ziptest.cgi # ############################################################################### # This is a little test script to see if you get zipping to work on your server. # Note that you need to have Compress::Zlib and Archive::Zip installed on your server. # If you configured this script correctly (below) then you should get a "File Download" # screen after you run this script in your browser. # # Use at your own risk! ############################################################################### # INSTRUCTIONS : #################### # (1) Rename this file 'ziptest.cgi' or 'ziptest.pl' #################### #################### # (2) UNIX users : please change the top line to your path to perl. #################### #################### # (3) Change below "$image_path" to path to image. #################### $image_path = '/home/http/html/www.domain.com/gallery/somimage.jpg'; #################### # (4) Change below "$zipfile_path" to the path of directory where your zipfile will be stored. # Unix users must set permissions on this directory to 777 #################### $zipfile_path = '/home/http/html/www.domain.com/zipped'; #################### # (5) Change below "$zipfile_url" to url of directory where your zipfile will be stored. #################### $zipfile_url = 'http://www.domain.com/zipped'; #################### # (6) Place this file in a executable directory on your server #################### #################### # (7) Set permissions on this file to 755 (UNIX) #################### #################### # (8) Call from any Web browser #################### ######################################################################## # No more editing needed. ######################################################################## $zipfile = "NewZip.zip"; $zipfile_path .= "/$zipfile"; $zipfile_url .= "/$zipfile"; use lib '.'; use Archive::Zip qw(:CONSTANTS :ERROR_CODES); my $zip = Archive::Zip->new(); $zip->addFile( $image_path, 'NewImageNameInZip.jpg' ); die 'write error' if $zip->writeToFileNamed( $zipfile_path ) != AZ_OK; print "Content-type: text/html\nLocation:$zipfile_url\n\n"; exit;