Php解压缩不起作用

时间:2013-06-02 10:34:02

标签: php ziparchive

我使用jQuery和https://github.com/jfeldstein/jQuery.AjaxFileUpload.js发布我的文件并尝试使用以下php解压缩:

    if($_FILES["folder"]["name"]) {
        $filename = $_FILES["folder"]["name"];
        $source = $_FILES["folder"]["tmp_name"];
        $type = $_FILES["folder"]["type"];

        $zip = new ZipArchive;     
        $res = $zip->open($source);
        if ($res === TRUE) {
             $zip->extractTo('themes');
             $zip->close();
             echo 'Unzip was successful';
        } else {
             echo 'Unzip was not successful';
        }

    } else {
        echo "NOT SET";            
    }

Firebug控制台返回“解压缩成功”,但主题文件夹中没有创建文件夹。任何人都可以建议为什么这不会创建文件夹?

2 个答案:

答案 0 :(得分:0)

   if ($res === TRUE) {
         $res = $zip->extractTo('themes');
         if ($res === TRUE) {
              echo 'Unzip was successful';
         }
    } 
    $zip->close();
    if ( $res === false ) {
         echo 'Unzip was not successful';
    }

答案 1 :(得分:0)

检查Web用户(Apache上的www-data)是否有权写入目标目录。