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

时间:2012-03-27 03:01:36

标签: php windows zip

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

由于某些原因,当我运行我的代码时,PHP返回ER_OPEN错误代码(11)并且我知道directoy是可写的,因为当这里上传的文件是我的脚本时文件被移动到父级

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] => ) ) 

任何帮助都会有所帮助

1 个答案:

答案 0 :(得分:3)

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

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