Home >php教程 >php手册 >php压缩和解压zip

php压缩和解压zip

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 19:35:291525browse

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();
                 }
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:递归创建文件目录Next article:php mysql 类