我有这个脚本,它在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自己的RarArchive
类:
这个类表示一个RAR档案,它可以由几个卷(部分)并且其包含多个RAR条目(即。,文件、目录和诸如符号链接之类的其他特殊对象)。