本文整理汇总了PHP中Zip::getZipFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Zip::getZipFile方法的具体用法?PHP Zip::getZipFile怎么用?PHP Zip::getZipFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zip
的用法示例。
在下文中一共展示了Zip::getZipFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AjaxMessageAttachmentsZip
/**
* @return array
*/
public function AjaxMessageAttachmentsZip()
{
$aHashes = $this->getParamValue('Hashes', null);
if (!is_array($aHashes) || 0 === count($aHashes) || !class_exists('ZipArchive')) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidInputParameter);
}
$mResult = false;
$oAccount = $this->getAccountFromParam();
$self = $this;
$aAdd = array();
foreach ($aHashes as $sHash) {
$this->rawCallback($sHash, function ($oAccount, $sContentType, $sFileName, $rResource) use($self, $sHash, &$aAdd) {
$sHash = md5($sHash . rand(1000, 9999));
if ($self->ApiFileCache()->putFile($oAccount, $sHash, $rResource)) {
$sFullFilePath = $self->ApiFileCache()->generateFullFilePath($oAccount, $sHash);
$aAdd[] = array($sFullFilePath, $sFileName, $sContentType);
}
}, false, $oAccount);
}
if (0 < count($aAdd)) {
include_once PSEVEN_APP_ROOT_PATH . 'libraries/other/Zip.php';
$oZip = new \Zip();
$sZipHash = md5(implode(',', $aHashes) . rand(1000, 9999));
foreach ($aAdd as $aItem) {
$oZip->addFile(fopen($aItem[0], 'r'), $aItem[1]);
}
$self->ApiFileCache()->putFile($oAccount, $sZipHash, $oZip->getZipFile());
$mResult = \CApi::EncodeKeyValues(array('TempFile' => true, 'AccountID' => $oAccount->IdAccount, 'Name' => 'attachments.zip', 'TempName' => $sZipHash));
}
return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
}
示例2: createDownloadPackage
//.........这里部分代码省略.........
'item_id' => $documentId,
'doc_id' => $documentId,
'value' => $fileObject->size,
'reference' => $fileId . ($version ? ':' . $version : '')
);
JUDownloadFrontHelperLog::addLog($logData);
}
}
}
// Only support download file/document, invalid type -> return false
else
{
return false;
}
$serverTime = JFactory::getDate()->toSql();
$serverTimeStamp = strtotime($serverTime);
// Store ID of download file(s) into session
if ($noCountingDownloadSecond > 0)
{
$storeIdArray = (array) $app->getUserState('com_judownload.download.storeid');
$storeIdArray[$serverTimeStamp] = $storeId;
$storeIdArray = array_unique($storeIdArray);
$app->setUserState('com_judownload.download.storeid', $storeIdArray);
}
// Last download time to calculate download interval
$session = JFactory::getSession();
$session->set('judl-last-download-time', $serverTime);
// If use zip class to zip files, set comment then close the archive
if ($zipFile)
{
// Set comment for zip file
$zip->setComment($zipComment);
// Close the archive
$zip->finalize();
}
// Send email by event for each document when download
$docIdArray = array();
if ($type == 'file')
{
$docIdArray[] = $parentId;
}
else
{
$docIdArray = $itemIdArray;
}
$docIdArray = array_unique($docIdArray);
//Send mail by event
foreach ($docIdArray AS $docId)
{
JUDownloadFrontHelperMail::sendEmailByEvent('document.download', $docId);
}
// Download ZIPPED file
if ($zipFile)
{
// Directly download(from zip resource by PHP)
$resourceFilePath = $zip->getZipFile();
$transport = 'php';
$speed = (int) $params->get('max_download_speed', 200);
$resume = $params->get('resume_download', 1);
$downloadMultiParts = $params->get('download_multi_parts', 1);
$downloadResult = JUDownloadHelper::downloadFile($resourceFilePath, $zipFileName, $transport, $speed, $resume, $downloadMultiParts);
if ($downloadResult !== true)
{
$this->setError($downloadResult);
return false;
}
}
// Download ONE NO ZIPPED file, in this case $zipFileName is the download file name, file can be zip file or not
else
{
// Directly download
$transport = $downloadOneFileNoZippedMode;
$speed = (int) $params->get('max_download_speed', 200);
$resume = $params->get('resume_download', 1);
$downloadMultiParts = $params->get('download_multi_parts', 1);
$downloadResult = JUDownloadHelper::downloadFile($physicalFilePath, $zipFileName, $transport, $speed, $resume, $downloadMultiParts);
if ($downloadResult !== true)
{
$this->setError($downloadResult);
return false;
}
}
return true;
}