I asked a question a couple of weeks ago about using Archive::Zip, and 
although my script does work, I still have a few queries about it; I wonder 
if anyone can shed any light.

The basic idea is that there are files of multiple formats (.doc, .pdf, 
.etc) that need to be downloaded through a users browser. It also needs to 
be downloaded through the program logic, and not as a simple link.

The main problem is that the zipped file downloads as "NameOfCGIFile.zip" 
and not "download.zip". I am also slightly more concerned about my 
(possibly pitiful) attempts at file locking, and the consequences of many 
users trying to download files at the same time. I've been playing around 
with this for some time, but I can't find a better way to do this.




($file - name from database query)

my $zip = Archive::Zip->new() or die "couldn't create zip $!";
$zip->addFile("/web/www.website.com/docs/$file") or die "couldn't add file $!";
$zip->writeToFileNamed('/web/www.website.com/docs/download.zip');# possible 
lock error";
open (DOCZIP, "/web/www.website.com/docs/download.zip") or die "couldn't 
open file $!";

flock (DOCZIP, 2);

print "Content-type:application/x-zip-compressed\n\n";

my $fileData;
while (read(DOCZIP, $fileData, 1024)) {
         print $fileData;
}

unlink ("/web/www.website.com/docs/download.zip") or die "couldn't delete 
file $!";

close(DOCZIP);





tia
Jon

*****************************************
  Jon Galliers   [EMAIL PROTECTED]
  Programmer     Perl/C++/MySQL/DB2/Java
  Design Net     http://www.design.net.uk
         Tel: +44(0)870 240 0088
         Fax: +44(0)870 240 0099
*****************************************

Reply via email to