zip文件已创建但未移至php中的文件夹

时间:2017-11-17 19:22:54

标签: php

文件正在上传并添加到zip中唯一的问题是将zip移动到所需的位置。权限是可以的我移动了单个文件。现在我想创建一个包含多个文件的zip,然后将该zip文件移动到文件夹。

$uploaddir = 'upload/page/';    

    if($_FILES['image_file_holder']['name'] != '')
    {   
        $total = count($_FILES['image_file_holder']['name']);
        echo $total;
        $imagarr = explode(".", "myserver.zip");                        
        $newimgfile = $imagarr[0]."_".mt_rand().'.'.$imagarr[1];
            $zipname = $newimgfile;
        $upload = $uploaddir . $newimgfile;
        $zip = new ZipArchive;
        $zip->open($zipname, ZipArchive::CREATE);
        for($i=0; $i<$total; $i++) {
                    //Get the temp file path
             $tmpFilePath = $_FILES['image_file_holder']['name'][$i];

             if ($tmpFilePath != ""){
                  $zip->addFile($tmpFilePath);


             }
        }
        $zip->close();



        echo "moving";

        if(move_uploaded_file($zipname,$upload))
        {
            echo "done";
        }
}

0 个答案:

没有答案