温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php如何安装php_rar扩展实现rar文件读取和解压

发布时间:2021-08-27 09:06:04 来源:亿速云 阅读:79 作者:小新 栏目:开发技术

小编给大家分享一下php如何安装php_rar扩展实现rar文件读取和解压,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

具体如下:

PHP Rar Archiving 模块 (php_rar) 是一个读取和解压rar文件的模块,但不提供RAR压缩(打包)的功能。

1.首先要到PECL的RAR页面下载DLL. 根据自己的情况选择下载对应版本的DLL.

PHP版本要求:php_rar模块适用于php 5.2及以上, 不过对于windows系统,似乎只有php5.3 / 5.4对应的DLL下载。

2.下载到的是个zip包,将其中的php_rar.pdb和php_rar.dll两个文件解压到PHP安装目录下的ext子目录中。

3.在php.ini中加入一行php_rar扩展引用声明 extension=php_rar.dll

4.如果使用Apache服务器,就需要重启Apache。IIS下以FastCGI模式加载的PHP则不需要进一步操作了。

5.写个测试文件看看有没有问题啊

6.如果有问题,查看服务器的日志文件。

附官方的测试代码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_open($archive_name) OR die('failed to open ' . $archive_name);
$entry = rar_entry_get($rar, $entry_name) OR die('failed to find ' . $entry_name . ' in ' . $archive_name);
// this will create all necessary subdirs under $dir_to_extract_to
$entry->extract($dir_to_extract_to); 
/* OR */
// this will create only one new file $new_entry_name in $dir_to_extract_to
$entry->extract('', $dir_to_extract_to.'/'.$new_entry_name); 
// this line is really not necessary
rar_close($rar);
?>

以上是“php如何安装php_rar扩展实现rar文件读取和解压”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI