当前位置: 首页>>代码示例>>PHP>>正文


PHP Zip::getFileExtAttr方法代码示例

本文整理汇总了PHP中Zip::getFileExtAttr方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::getFileExtAttr方法的具体用法?PHP Zip::getFileExtAttr怎么用?PHP Zip::getFileExtAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zip的用法示例。


在下文中一共展示了Zip::getFileExtAttr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

\PHPZip\Zip\File\Zip::$temp = function() { return "./tempFile_" . rand(100000, 999999);};

$zip = new \PHPZip\Zip\File\Zip(); // $zip = new Zip();
// Archive comments don't really support utf-8. Some tools detect and read it though.
$zip->setComment("Example Zip file.\nCreated on " . date('l jS \of F Y h:i:s A'));
$zip->addFile("Hello World!", "hello.txt");

@$handle = opendir($fileDir);
if ($handle) {
	/* This is the correct way to loop over the directory. */
	while (false !== ($file = readdir($handle))) {
		if (strpos($file, ".php") !== false) {
			$pathData = pathinfo($fileDir . $file);
			$fileName = $pathData['filename'];

			$zip->addFile(file_get_contents($fileDir . $file), $file, filectime($fileDir . $file), NULL, TRUE, Zip::getFileExtAttr($file));
		}
	}
}

// Uses my Lipsum generator from https://github.com/Grandt/PHPLipsumGenerator
if(file_exists('./LipsumGenerator.php')) {
	require_once './LipsumGenerator.php';
	$lg = new com\grandt\php\LipsumGenerator();
	$zip->openStream("big one3.txt");
	for ($i = 1 ; $i <= 20 ; $i++) {
		$zip->addStreamData("Chapter $i\r\n\r\n" . $lg->generate(300, 2500) . "\r\n");
	}
	$zip->closeStream();
}
$zip->sendZip("ZipExample3.zip", "application/zip", "ZipExample3.zip");
开发者ID:Grandt,项目名称:PHPZip,代码行数:31,代码来源:Zip.Example3.php

示例2: scanner


//.........这里部分代码省略.........
                 echo $error_msg;
                 self::UpdateProgressValue($current_task, $total_tasks, $error_msg);
                 if (self::$debug) {
                     self::DebugLog($error_msg);
                 }
                 exit;
             }
         } else {
             $error_msg = 'Error: ZipArchive class is not exist.';
             if (self::$debug) {
                 self::DebugLog($error_msg);
             }
         }
         $error_msg = 'ZipArchive method - finished';
         if (self::$debug) {
             self::DebugLog($error_msg);
         }
         // Check if zip file exists
         if (!file_exists($file_zip)) {
             $error_msg = 'Error: zip file is not exists. Use OwnZipClass';
             if (self::$debug) {
                 self::DebugLog($error_msg);
             }
             $error_msg = 'OwnZipClass method - started';
             if (self::$debug) {
                 self::DebugLog($error_msg);
             }
             $zip = new Zip();
             $zip->setZipFile($file_zip);
             foreach ($files_list as $file_name_short) {
                 $file_name = trim($this->scan_path . $file_name_short);
                 $handle = fopen($file_name, "r");
                 if (filesize($file_name) > 0) {
                     $zip->addFile(fread($handle, filesize($file_name)), $file_name_short, filectime($file_name), NULL, TRUE, Zip::getFileExtAttr($file_name));
                 }
                 fclose($handle);
             }
             $zip->finalize();
             $error_msg = 'OwnZipClass method - finished';
             if (self::$debug) {
                 self::DebugLog($error_msg);
             }
             $ssh_flag = false;
         }
     }
     // Update progress
     $current_task += 1;
     self::UpdateProgressValue($current_task, $total_tasks, 'Collecting information about the files.');
     /**
      * Send files to SG server
      */
     if ($ssh_flag) {
         $archive_filename = $this->tmp_dir . "pack.tar";
         $archive_format = 'tar';
     } else {
         $archive_filename = $this->tmp_dir . "pack.zip";
         $archive_format = 'zip';
     }
     $error_msg = 'Pack file: ' . $archive_filename;
     if (self::$debug) {
         self::DebugLog($error_msg);
     }
     // Check if pack file is exist
     if (file_exists($archive_filename) === false) {
         $error_msg = 'Error: Pack file is not exist. Probably not enough space on the server.';
         if (self::$debug) {
开发者ID:nhathong1204,项目名称:bdshungthinh,代码行数:67,代码来源:scanner.class.php


注:本文中的Zip::getFileExtAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。