本文整理匯總了PHP中DataGenerator::getExportTarget方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataGenerator::getExportTarget方法的具體用法?PHP DataGenerator::getExportTarget怎麽用?PHP DataGenerator::getExportTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DataGenerator
的用法示例。
在下文中一共展示了DataGenerator::getExportTarget方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: DataGenerator
<?php
require_once __DIR__ . "/library.php";
Core::init("generation");
$gen = new DataGenerator(Constants::GEN_ENVIRONMENT_POST, $_POST);
$response = $gen->generate();
if ($gen->getExportTarget() == "promptDownload") {
header("Cache-Control: private, no-cache, must-revalidate");
// check if user opted to zip the generated data
if ($gen->isPromptDownloadZipped()) {
$randNum = mt_rand(0, 100000000);
$fileName = $randNum . "_" . $response["promptDownloadFilename"];
$zipPath = $filePath . ".zip";
if (file_put_contents($fileName, $response["content"])) {
// now that we've written the file, zip it up
$zip = new ZipArchive();
$zipFile = $zip->open($zipPath, ZipArchive::CREATE);
if ($zipFile && $zip->addFile($fileName, $response["promptDownloadFilename"])) {
// we've got our zip file now we may set the response header
$zip->close();
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=" . $response["promptDownloadFilename"] . ".zip");
readfile($zipPath);
unlink($zipPath);
unlink($fileName);
exit;
}
}
// no compression, send the original data back
} else {
header("Content-Type: {$response["contentTypeHeader"]}");