При попытке создать файл экспорта возникла ошибка.
Я использую PHP.
Код такой:
Код: Выделить всё
$directory = Yii::getAlias('@console/runtime/tmp');
if (!file_exists($directory)) {
mkdir($directory);
}
$this->zip = new \ZipArchive();
$this->zipFile = tempnam($directory, "zip");
....
$html = 'noname';
$output = '';
$output .= "\n";
$output .= "\n";
$output .= "\n";
$output .= "\n";
$output .= "\n";
$output .= $html;
$output .= "\n";
$output .= "\n";
$fileName = "test" . '.xls';
if ($this->zip->open($this->zipFile, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) {
file_put_contents($fileName, $output);
$this->zip->addFile($fileName, basename($fileName));
}
$this->zip->close();
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename=' . $this->getFilename());
header("Content-Length: " . filesize($this->zipFile));
header("Pragma: no-cache");
header("Expires: 0");
readfile($this->zipFile);
exit();

Что мне сделать, чтобы все заработало? Я уже потратил 3 дня на эту проблему
Подробнее здесь: https://stackoverflow.com/questions/784 ... -terminals