PHP rar文件`s其他方式

时间:2013-11-30 09:21:59

标签: 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]}\" ";
    }
    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文件?

1 个答案:

答案 0 :(得分:0)

您可以使用PHP自己的RarArchive类:

  

此类表示RAR存档,可由多个存档构成   卷(部分),其中包含许多RAR条目(即,   文件,目录和其他特殊对象,如符号链接)。