这是我正在尝试上传 zip 并在某个位置提取 zip 的代码 -
//Path where extracted files to be stored, path is correct already checked
$path = Mage::getBaseDir(). DS .'pdf_locator'. DS;
$zip = new ZipArchive;
echo "<pre>";print_r($_FILES);
echo $_FILES['filename']['name'];
$name = $_FILES['filename']['name'];
$res = $zip->open("$name");//File name in server.
echo " --- ", $res, " --- ";
die;
if ($res === TRUE) {
$zip->extractTo($path);//Destination directory
$zip->close();
echo 'successfully extracted';
} else {
echo 'failed';
}
输出 -
Array
(
[filename] => Array
(
[name] => swap.zip
[type] => application/zip
[tmp_name] => /tmp/phpqx2qH2
[error] => 0
[size] => 478441
)
)
swap.zip --- 11 ---
我期待TRUE
,但它正在抛出错误代码11
[来自文档]。让我知道我对代码做错了什么。
仅供参考 - Zip 已启用,请查看屏幕截图。