PHP rar文件的另一种方式

PHP rar文件的另一种方式,php,rar,Php,Rar,我有这个脚本,它在XAMMP(windows)下工作得很好,但是当我将它上传到我的主机时,它会失败吗 出于安全原因,已禁用exec() 和.exe在linux上不起作用 <?php error_reporting(E_ALL); function RARFiles($Output='output.rar',$Files=array()) { $Data=''; for($i=0;$i<count($Files);$i++) { $Data.="\"{$Files[$i

我有这个脚本,它在XAMMP(windows)下工作得很好,但是当我将它上传到我的主机时,它会失败吗

出于安全原因,已禁用exec()

和.exe在linux上不起作用

<?php
error_reporting(E_ALL);
function RARFiles($Output='output.rar',$Files=array()) {
  $Data='';
  for($i=0;$i<count($Files);$i++) {
    $Data.="\"{$Files[$i]}\" ";
    }
    exec("rar.exe a \"{$Output}\" {$Data}");
    if(file_exists($Output)) {
        echo 'ok';
    } else {
        echo 'failed';
    }
}

$Files=array('index.php');
RARFiles('./Hier_je_files/asdf.rar',$Files);
?>

有没有其他方法可以使用php来rar文件?

您可以使用php自己的类:

这个类代表一个RAR档案,它可以由几个 卷(部分)和包含多个RAR条目(即。, 文件、目录和其他特殊对象(如符号链接)


PHP有几个压缩扩展。请查看您的
phpinfo()
输出,以检查您的主机上是否安装了这些压缩扩展…LMGTFY: