Leser: 19
1 2 3 4 5 6 7 8 9 10
[...] my $zip = Archive::Zip->new(); my $archive = "path/file.zip"; die "can't read .zip" unless $zip->read($archive) == AZ_OK; # Hier evtl. die Dateien umbenennen bevor sie entpackt werden?? # my @members = $zip->memberNames(); $zip->extractTree('', "path/folder/"); [...]
1 2 3 4 5 6 7 8 9
my $zip = Archive::Zip->new(); my $archive = "path/file.zip"; die "can't read .zip" unless $zip->read($archive) == AZ_OK; my @members = $zip->memberNames; foreach my $member(@members) { my $newMemberName = ...; $zip->extractMember($member, $newMemberName); }
QuotefileName()
Get or set the member's internal filename. Returns the (possibly new) filename. Names will have backslashes converted to forward slashes, and will have multiple consecutive slashes converted to single ones.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
my $zip = Archive::Zip->new(); my $archive = "$upload_dir/$file"; die "can't read .zip" unless $zip->read($archive) == AZ_OK; my @members = $zip->memberNames; foreach my $member(@members) { my @member_parts = split(/\./,$member); my $file_id = int(rand(10000000)); my $newMemberName = "../fotos/$album/$file_id\."."$member_parts[1]"; my $db_name = "$file_id\."."$member_parts[1]"; $zip->extractMember($member, $newMemberName); my $sql_insert = "INSERT into fotos VALUES('','$db_name','')"; my $prepare_insert = $dbh->prepare( $sql_insert ) || die $dbh->errstr; $prepare_insert->execute() ; $dbh->disconnect(); unlink $member; } unlink $archive;