in reply to Unzipping files using Archive::Zip
What part of the Archive::Zip docs did you find confusing? I'm always looking to improve them.
Assuming that your uploaded .zip file is sitting in a real file, it's pretty easy to use Archive::Zip. You do have to decide how you'll map directory names (since I'm assuming you don't want to clobber existing files with the same name on the server); you could, perhaps, just delete the directory path and stick the unzipped files somewhere. You might also want to provide some kind of semaphoring or other protection, but that isn't Archive::Zip's job, of course.
Just extracting a zip file is easy. This quick example extracts a zip file, throwing away the directories and directory names (note that there is no error checking here):
use Archive::Zip; my $zipname = 'whatever.zip'; my $destinationDirectory = '/some/where'; my $zip = Archive::Zip->new($zipname); foreach my $member ($zip->members) { next if $member->isDirectory; (my $extractName = $member->fileName) =~ s{.*/}{}; $member->extractToFileNamed( "$destinationDirectory/$extractName"); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Unzipping files using Archive::Zip
by Anonymous Monk on Mar 18, 2005 at 16:23 UTC | |
by bondsuperman (Initiate) on Sep 26, 2011 at 13:55 UTC | |
by marto (Cardinal) on Sep 26, 2011 at 13:57 UTC | |
by Anonymous Monk on Sep 27, 2011 at 01:24 UTC | |
Re: Re: Unzipping files using Archive::Zip
by wanadlan (Initiate) on Jan 28, 2003 at 21:21 UTC | |
by Anonymous Monk on Mar 18, 2005 at 15:45 UTC |
In Section
Seekers of Perl Wisdom