php压缩和解压zip 无 // 压缩zip$zip_c = new ZipArchive;$res = $zip_c-open('./g_file/file.zip', ZipArchive::CREATE);if ($res === TRUE) { $zip_c-addFile('./g_file/grain.txt','grain.txt'); // 将文件添加的压缩包中$zip_c-addFile('./g_file/granary

php压缩和解压zip
      // 压缩zip
	$zip_c = new ZipArchive;	
	$res = $zip_c->open('./g_file/file.zip', ZipArchive::CREATE);
	if ($res === TRUE) { 
		$zip_c->addFile('./g_file/grain.txt','grain.txt');  // 将文件添加的压缩包中
		$zip_c->addFile('./g_file/granary.txt','granary.txt');
		$zip_c->addFile('./g_file/sensor.txt','sensor.txt');
		$zip_c->addFile('./g_file/data.txt','data.txt'); 
		$zip_c->close(); //关闭
		$url='http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]; 
		$dir_url_http=dirname($url).'/';
		operation_log($uname,"下载数据");
		echo "{\"s\":\"0\",\"url\":\"{$dir_url_http}g_file/file.zip\"}";
	}

       //  解压zip
		$zip = new ZipArchive;
		$res = $zip->open('./u_file/file.zip');
		if ($res === TRUE) {
			$zip->extractTo('./u_file/');
			$zip->close();
                 }
登录后复制

09-18 23:39