PHP installation Php_rar extension implementation RAR file read and decompression method

Source: Internet
Author: User
This article describes the PHP installation Php_rar extension implementation of RAR file read and decompression method. Share to everyone for your reference, as follows:

The PHP RAR archiving Module (PHP_RAR) is a module that reads and compresses RAR files, but does not provide RAR compression (packaging) functionality.

1. First to download the DLL to the PECL RAR page. Choose to download the corresponding version of the DLL, depending on your situation.

PHP Version requirements: Php_rar module for PHP 5.2 and above, but for Windows systems, it seems that only the php5.3/5.4 corresponding DLL download.

2. Download to a ZIP package and extract the php_rar.pdb and php_rar.dll two files into the ext subdirectory of the PHP installation directory.

3. Add a row Php_rar extension reference declaration in PHP.ini Extension=php_rar.dll

4. If you use Apache server, you will need to restart Apache. PHP, which is loaded in fastcgi mode under IIS, does not require further action.

5. Write a test file to see if there's a problem.

6. If there is a problem, view the log file for the server.

Attached to the official test code test-rar.php:

<?php$archive_name = '/full/path/to/file.rar ' $entry _name = ' path/to/archive/entry.txt '; Notice:no slash at the beginning$dir_to_extract_to = '/path/to/extract/dir '; $new _entry_name = ' some.txt '; $rar = Rar_op En ($archive _name) or Die ("Failed to open". $archive _name); $entry = Rar_entry_get ($rar, $entry _name) or Die (' failed to fi nd '. $entry _name. ' In '. $archive _name);//This would create all necessary subdirs under $dir _to_extract_to$entry->extract ($dir _to_extract_to ),/* or *///This would create only one new file $new _entry_name in $dir _to_extract_to$entry->extract (", $dir _to_extrac T_to. ' /'. $new _entry_name);//This line was really not necessaryrar_close ($rar);? >
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.