downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Rar Functions> <Predefined Constants
Last updated: Fri, 06 Nov 2009

view this page in

Examples

Example #1 Rar extension overview example

<?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);

?>

This example opens a Rar file archive and extracts each entry to the specified directory.



add a note add a note User Contributed Notes
Examples
landavia81 at gmail dot com
21-Jan-2009 06:00
for unknown reason.. many programer has problem with php_rar (in windows).. i came up with this ... and it work.

basicly is same as above but only extract only. The problem will come up if the file rar corrupt, exist and soon
_______________________________
<?php
$appRar
="C:/Program Files/WinRAR/unrar.exe"
#this is false..
  
$appRar = '"C:\Program Files\WinRAR\unrar.exe"';
#change this
$opt="e";
$target="1.rar";

$do ="$appRar $opt $target";

exec($do,$aOut);
print_r($aOut);

?>
-------------------------------------------------
For windows user: try using bat file for test.

all user: please read man unrar, above using e because this only extract. But you should notice about other option like "y","x", etc

i type the option here if you too lazy
http://landavia.multiply.com/journal/item/284/option_for_unrar

$aOut are array for the output after you run the script $do

Rar Functions> <Predefined Constants
Last updated: Fri, 06 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites