コード例 #1
0
ファイル: ZipStream.Example2b.php プロジェクト: Grandt/PHPZip
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-39.jpg"), "images/rossi-perfectisboring-39.jpg");
$f .= "\r\n39: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-40.jpg"), "images/rossi-perfectisboring-40.jpg");
$f .= "\r\n40: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-41.jpg"), "images/rossi-perfectisboring-41.jpg");
$f .= "\r\n41: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-42.jpg"), "images/rossi-perfectisboring-42.jpg");
$f .= "\r\n42: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-43.jpg"), "images/rossi-perfectisboring-43.jpg");
$f .= "\r\n43: " . getMem();
$zip->addLargeFile(\RelativePath::pathJoin($testPath, "images/rossi-perfectisboring-44.jpg"), "images/rossi-perfectisboring-44.jpg");
$f .= "\r\n44: " . getMem();

$f .= "\r\n\r\nFinal:" . getMem();

$zip->addFile($f, "mem.txt");
$rv = $zip->finalize();

// If non-fatal errors occurred during execution, this will append them
//  to the end of the generated file.
// It'll create an invalid Zip file, however chances are that it is invalid
//  already due to the error happening in the first place.
// The idea is that errors will be very easy to spot.
if (!empty($errors)) {
	echo "\n<pre>\n**************\n*** ERRORS ***\n**************\n\n$errors\n</pre>\n";
}

function getMem() {
    global $tLast;
    global $tStart;
    global $mLast;
コード例 #2
0
ファイル: ZipStream.Example1.php プロジェクト: Grandt/PHPZip
// new \PHPZip\Zip\Stream\ZipStream(
// The parameters are unchanged.

require_once('bootstrap.php'); // include_once("ZipStream.php");
//print_r(ini_get_all());

$fileTime = date("D, d M Y H:i:s T");

$chapter1 = "Chapter 1\n"
		. "Lorem ipsum\n"
		. "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);
}
コード例 #3
0
ファイル: ZipStream.Example1s.php プロジェクト: Grandt/PHPZip
$fileTime = date("D, d M Y H:i:s T");

$chapter1 = "Chapter 1\n"
		. "Lorem ipsum\n"
		. "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n";

//$zip = new ZipStream("ZipStreamExample1s.zip");
//$zip = new ZipStream("ZipStreamExample1s_€2,000.zip");
$zip = new \PHPZip\Zip\Stream\ZipStream("ZipStreamExample1s_€2,000.zip", "application/zip", "ZipStreamExample1s_€2,000_utf8.zip");
    // $zip = new ZipStream("ZipStreamExample1s_€2,000.zip", "application/zip", "ZipStreamExample1s_€2,000_utf8.zip");

// Archive comments don't really support utf-8. Some tools detect and read it though.
$zip->setComment("Example Zip file for Large file sets.\nАрхив Комментарий\nCreated on " . date('l jS \of F Y h:i:s A'));

// A bit of russian (I hope), to test UTF-8 file names.
$zip->addFile("Привет мир!", "Кириллица имя файла.txt");
$zip->addFile("Привет мир!", "Привет мир. С комментарий к файлу.txt", 0, "Кириллица файл комментарий");


$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();

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

$zip->finalize(); // Mandatory, needed to send the Zip files central directory structure.

// If non-fatal errors occurred during execution, this will append them
//  to the end of the generated file.