PHP library that can list contents of zip / rar files [closed]

一曲冷凌霜 提交于 2019-12-12 15:30:45

问题


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.


回答1:


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.




回答2:


http://us2.php.net/manual/en/ref.zip.php for zip-files.

http://us2.php.net/manual/en/rararchive.getentries.php for rar-files.




回答3:


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:


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



来源:https://stackoverflow.com/questions/1524186/php-library-that-can-list-contents-of-zip-rar-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!