PHP library that can list contents of zip / rar fi

2019-07-07 01:15发布

Note: I NEED A LIBRARY not links to documentation about extensions my host doesn't have or want installed.

The subject says it all.

I don't need to extract any files for the moment (although that might be a nice addition to my web app later) I just need to list the contents of rar and zip archives.

4条回答
该账号已被封号
2楼-- · 2019-07-07 01:21

phpinfo(); you webhost

if you see this Rar support the you can use PECL's rar functions.

This class can make things simple

Or else I don't know if this is possible

查看更多
Ridiculous、
3楼-- · 2019-07-07 01:35

PHP Compression Functions

everything you need (installation, usage examples) is included in that page.

listing rar files is as easy as

<?php

 $rar_file = rar_open('example.rar') or die("Can't open Rar archive");

 $entries = rar_list($rar_file);

 foreach ($entries as $entry) {
     echo 'Filename: ' . $entry->getName() . "\n";
     echo 'Packed size: ' . $entry->getPackedSize() . "\n";
     echo 'Unpacked size: ' . $entry->getUnpackedSize() . "\n";

     $entry->extract('/dir/extract/to/');
 }

 rar_close($rar_file);

 ?>
查看更多
手持菜刀,她持情操
4楼-- · 2019-07-07 01:42

I honestly don't think you'll find one. What you're asking for is a library that includes the rar extension (giving php access and usability to the filesystem and compressed files: rar) itself if I'm understanding correctly. I really don't think anyone would go through the trouble of rebuilding/porting/moving/extracting/etc the rar extension when it's easier to install it. If I were you I'd contact the host to see if they'll install it and/or migrate to a new host.

查看更多
登录 后发表回答