tags:

views:

478

answers:

1

Hello,

how to unrar files using php on windows? Is there any script or codes to make it possible?

Thanks

+4  A: 

Check this link out:

http://us2.php.net/manual/en/book.rar.php

Using that extension, you can do something like this:

$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);
Paolo Bergantino
do you know any scripts or so? because im quite begineer in php.
I added a code sample. It doesn't get any simpler than that. :)
Paolo Bergantino
Fatal error: Call to undefined function rar_open() in C:\xampp\htdocs\unrar.php on line 2I get this error when using your code.
@loek32z you'll need to set up the package first - check out http://us2.php.net/manual/en/rar.installation.php
ConroyP
I cant find php_rar.dll inside pecl 5.2.5 win 32 binaries. Anywhere else can i find it?