gpt4 book ai didi

PHP 不会在 Windows 上提取 zip 文件 ER_OPEN

转载 作者:可可西里 更新时间:2023-11-01 11:36:35 28 4
gpt4 key购买 nike

我正在为我的 CMS 构建模块安装程序,现在我在使用安装了 XAMPP x32 的 Windows 7 x64 时遇到了问题,

出于某种原因,每当我运行我的代码时,PHP 都会返回 ER_OPEN 错误代码 (11),并且我知道目录是可写的,因为文件在上传时会被 php 移动到父级,这里是我的脚本

if($_URL['form'] == 'sent'){
$target_path = getcwd()."\\..\\Temp-uplds\\";
$target_path = $target_path. time() . basename( $_FILES['installFile']['name']);

if(move_uploaded_file($_FILES['installFile']['tmp_name'], $target_path)) {
$zip = new ZipArchive;
$status = $zip->open('$target_path');
if ($status === TRUE) {
$zip->extractTo(getcwd()."\\..\\Temp-uplds\\zip\\");
$zip->close();
} else {
print_r(array($status, $zip));
}
} else{
$this->tmp_vars->error = true;
}

}

echo "<pre>error codes ZIPARCHIVE::ER_EXISTS = '".ZIPARCHIVE::ER_EXISTS."'
File already exists.
ZIPARCHIVE::ER_INCONS = '".ZIPARCHIVE::ER_INCONS."'
Zip archive inconsistent.
ZIPARCHIVE::ER_INVAL = '".ZIPARCHIVE::ER_INVAL."'
Invalid argument.
ZIPARCHIVE::ER_MEMORY = '".ZIPARCHIVE::ER_MEMORY."'
Malloc failure.
ZIPARCHIVE::ER_NOENT = '".ZIPARCHIVE::ER_NOENT."'
No such file.
ZIPARCHIVE::ER_NOZIP = '".ZIPARCHIVE::ER_NOZIP."'
Not a zip archive.
ZIPARCHIVE::ER_OPEN = '".ZIPARCHIVE::ER_OPEN."'
Can't open file.
ZIPARCHIVE::ER_READ = '".ZIPARCHIVE::ER_READ."'
Read error.
ZIPARCHIVE::ER_SEEK = '".ZIPARCHIVE::ER_SEEK."' </pre>";

我的 Given 输出是

Array ( [0] => 11 [1] => ZipArchive Object ( [status] => 0 [statusSys] => 0 [numFiles] => 0 [filename] => [comment] => ) ) 

任何帮助都会有帮助

最佳答案

“$target_path”周围有单引号。变量插值仅适用于双引号。

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double

关于PHP 不会在 Windows 上提取 zip 文件 ER_OPEN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9882813/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com