Ejemplo n.º 1
0
 /**
  */
 public function pluginExportHandle($plugin_name = '')
 {
     $plugin_path = 'Addons/' . $plugin_name . '/';
     $temp_path = WEB_CACHE_PATH;
     File::delDir(WEB_CACHE_PATH);
     File::mkDir(WEB_CACHE_PATH);
     $file_path = $temp_path . "\\" . 'GCS_Plugin-' . $plugin_name . '-' . md5(time()) . '.zip';
     $zip = new \ZipArchive();
     //新建一个ZipArchive的对象
     $res = $zip->open($file_path, \ZipArchive::CREATE);
     if ($res == true) {
         PHPZip::folderToZip($plugin_path, $zip);
         $zip->close();
     }
     if (!File::file_exists($file_path)) {
         $this->error("该文件不存在,可能是被删除");
     }
     $filename = basename($file_path);
     header("Content-type: application/octet-stream");
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     header("Content-Length: " . filesize($file_path));
     readfile($file_path);
 }