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"); }
In reply to Re: Unzipping files using Archive::Zip
by bikeNomad
in thread Unzipping files using Archive::Zip
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |