how to rar files unrar through php script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hyungKim
    New Member
    • Jan 2013
    • 6

    #1

    how to rar files unrar through php script

    Code:
    <?php
    $rar_arch = RarArchive::open('', '');
    if ($rar_arch === FALSE)
        die("Failed opening file");
        
    $entries = $rar_arch->getEntries();
    if ($entries === FALSE)
        die("Failed fetching entries");
    
    echo "Found " . count($entries) . " ";
    
    if (empty($entries))
        die("No valid entries found.");
        
    $stream = reset($entries)->getStream();
    if ($stream === FALSE)
        die("Failed opening first file");
    
    $rar_arch->close();
    
    echo "Content of first one follows:\n";
    echo stream_get_contents($stream);
    
    fclose($stream);
    ?>

    Error is:
    Fatal error: Class 'RarArchive' not found in C:\Zend\Apache2 \htdocs\CSV\ema il1.php on line 2 .....
Working...