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

php压缩和解压zip

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:35:29
Original
1526 people have browsed it

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();
                 }
Copy after login
Related labels:
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template