コード例 #1
0
ファイル: ZipStream.Example1.php プロジェクト: Grandt/PHPZip
		. "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec magna lorem, mattis sit amet porta vitae, consectetur ut eros. Nullam id mattis lacus. In eget neque magna, congue imperdiet nulla. Aenean erat lacus, imperdiet a adipiscing non, dignissim eget felis. Nulla facilisi. Vivamus sit amet lorem eget mauris dictum pharetra. In mauris nulla, placerat a accumsan ac, mollis sit amet ligula. Donec eget facilisis dui. Cras elit quam, imperdiet at malesuada vitae, luctus id orci. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque eu libero in leo ultrices tristique. Etiam quis ornare massa. Donec in velit leo. Sed eu ante tortor.\n";

$zip = new \PHPZip\Zip\Stream\ZipStream('ZipStreamExample1.zip'); // $zip = new ZipStream("ZipStreamExample1.zip");

$zip->setComment("Example Zip file for Large file sets.\nCreated on " . date('l jS \of F Y h:i:s A'));
$zip->addFile("Hello World!\r\n", "Hello.txt");

$zip->openStream("big one3.txt");
$zip->addStreamData($chapter1."\n\n\n");
$zip->addStreamData($chapter1."\n\n\n");
$zip->addStreamData($chapter1."\n\n\n");
$zip->closeStream();

// For this test you need to create a large text file called "big one1.txt"
if (file_exists("big one1.txt")) {
	$zip->addLargeFile("big one1.txt", "big one2a.txt", 0, null, \PHPZip\Zip\Core\ZipUtils::getFileExtAttr("big one1.txt"));

	$fhandle = fopen("big one1.txt", "rb");
	$zip->addLargeFile($fhandle, "big one2b.txt");
	fclose($fhandle);
}

$zip->addDirectory("Empty Dir");

//Dir test, using the stream option on $zip->addLargeFile
$fileDir = './';
@$handle = opendir($fileDir);
if ($handle) {
	/* This is the correct way to loop over the directory. */
	while (false !== ($file = readdir($handle))) {
		if (($file != '.') && ($file != '..') && is_file($file)) {
コード例 #2
0
ファイル: ZipStream.Example2b.php プロジェクト: Grandt/PHPZip
/*
 * As seen in the output, the above construct with a PHP end and start tag after
 * creating the ZipStream is a bad idea. The Zip file will be starting with a
 * space followed by the newline characters.
 */
$testPath = \RelativePath::pathJoin("..", "testData");

//$zip->addDirectory("images");

//$zip->addDirectoryContent("testData" . DIRECTORY_SEPARATOR . "test","test");
//$zip->addLargeFile(\RelativePath::pathJoin($testPath, "500k.tc"), "test/500k.tc");
//$zip->addLargeFile(\RelativePath::pathJoin($testPath, "750k.tc"), "test/750k.tc");
//$zip->addLargeFile(\RelativePath::pathJoin($testPath, "1m.tc"), "test/1m.tc");
$f .= "\r\n";
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-01.jpg"), "images/rossi-perfectisboring-01.jpg");
$f .= "\r\n01: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-02.jpg"), "images/rossi-perfectisboring-02.jpg");
$f .= "\r\n02: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-03.jpg"), "images/rossi-perfectisboring-03.jpg");
$f .= "\r\n03: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-04.jpg"), "images/rossi-perfectisboring-04.jpg");
$f .= "\r\n04: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-05.jpg"), "images/rossi-perfectisboring-05.jpg");
$f .= "\r\n05: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-06.jpg"), "images/rossi-perfectisboring-06.jpg");
$f .= "\r\n06: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-07.jpg"), "images/rossi-perfectisboring-07.jpg");
$f .= "\r\n07: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-08.jpg"), "images/rossi-perfectisboring-08.jpg");
$f .= "\r\n08: " . getMem();