/g/content/download-zipped/dinges.pdf,jadda.gif/myZipArchiveName

@return Void
550142
public function downloadzippedAction() {
        $params = $this->getRequest()->getParams();

        if (!array_key_exists('files', $params)
            || !array_key_exists('zipname', $params)
            || !$params['files']
            || !$params['zipname']
        ) {
            throw new Exception('Please provide a filename list, and a name for the archive.');
        }

        $zip = new ZipArchive();
        $tmpDir = sys_get_temp_dir();
        $tmpDir .= $tmpDir[strlen($tmpDir) - 1] !== '/' ? '/' : '';
        $zipPath = $tmpDir . $params['zipname'] . '.zip';

        if ($zip->open($zipPath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== true) {
            throw new Exception("Cannot open <$zipPath>\n");
        }

        //  @todo: als cdn niet lokaal is, moet je waarschijnlijk met zip::addFromString werken.
        $filenames = explode(',', $params['files']);

        $image = new Garp_Image_File(Garp_File::FILE_VARIANT_UPLOAD);
        $document = new Garp_File(null, Garp_File::FILE_VARIANT_UPLOAD);
        $ini = Zend_Registry::get('config');
        $cdnIsLocal = $ini->cdn->type === "local";

        foreach ($filenames as $filename) {
            $allowedImageExtensions = $image->getAllowedExtensions();
            $filenameParts = explode('.', $filename);
            $extension = $filenameParts[count($filenameParts) - 1];

            $fileIsImage = in_array($extension, $allowedImageExtensions);

            $file = $fileIsImage ? $image : $document;

            $url = $file->getUrl($filename);
            if ($content = @file_get_contents($url)) {
                $zip->addFromString('/' . $params['zipname'] . '/' . $filename, $content);
            } else {
                throw new Exception("{$url} could not be opened for inclusion in the zip archive.");
            }
        }

        $zip->close();

        $this->_downloadFile($zipPath);
        @unlink($zipPath);
    }
716542
public function returnZipFile() {
        chdir(codemonkey_pathTempDir);
        $zipname = $this->config['projectname'].".zip";
        $zip = new ZipArchive();
        $zip->open($zipname, ZipArchive::CREATE);

        foreach ($this->listTempDir() as $file) {
            $zip->addFile($file);
        }
        $zip->close();

        header('Content-Type: application/zip');
        header('Content-disposition: attachment; filename='.$zipname);
        header('Content-Length: ' . filesize($zipname));
        readfile(codemonkey_pathTempDir.$zipname);
        unlink($zipname);
        $this->clearTempFolder();
        exit();
    }
1148484
public function downloadFile()
	{
		if($this->hasRequestParameter('id')){
			$fileService = $this->getServiceLocator()->get(FileReferenceSerializer::SERVICE_ID);
			$file = $fileService->unserialize($this->getRequestParameter('id'));
			header("Content-Disposition: attachment; filename=\"{$file->getBasename()}\"");
			tao_helpers_Http::returnStream($file->readPsrStream(), $file->getMimeType());
		}

	}
1184174
private function gzipCompressOptimizedResourceFiles(): void
  {
    $this->logInfo('Gzip compressing files.');

    foreach ($this->getResourcesInfo() as $file_info)
    {
      $this->logVerbose("Gzip compressing file '%s' to '%s'.",
                        $file_info['full_path_name_with_hash'],
                        $file_info['full_path_name_with_hash'].'.gz');

      // Get data from the file.
      $data_opt = file_get_contents($file_info['full_path_name_with_hash']);
      if ($data_opt===false)
      {
        $this->logError("Can not read the file '%s' or file does not exist.", $file_info['full_path_name_with_hash']);
      }

      // Compress data with gzip
      $data_gzip = gzencode($data_opt, 9);
      if ($data_gzip===false)
      {
        $this->logError("Can not write the file '%s' or file does not exist.",
                        $file_info['full_path_name_with_hash'].'.gz');
      }

      if (strlen($data_gzip)<strlen($data_opt))
      {
        // Write data to the file.
        $status = file_put_contents($file_info['full_path_name_with_hash'].'.gz', $data_gzip);
        if ($status===false)
        {
          $this->logError("Unable to write to file '%s", $file_info['full_path_name_with_hash'].'.gz');
        }

        // If required preserve mtime.
        if ($this->preserveModificationTime)
        {
          $info  = $this->getResourceInfoByHash($file_info['full_path_name_with_hash']);
          $mtime = $info['mtime'];
          $this->setModificationTime($file_info['full_path_name_with_hash'].'.gz', $mtime);
        }

        // If required preserve file permissions.
        clearstatcache();
        if ($this->preserveModificationTime && fileperms($file_info['full_path_name_with_hash'])!==false)
        {
          $this->setFilePermissions($file_info['full_path_name_with_hash'].'.gz', $file_info['full_path_name_with_hash']);
        }
      }
    }
  }
842584
public function download($filename) {
    if(!empty($this->pdf->getError())) {
      throw new Exception('Could not create PDF: ' . $this->pdf->getError());
    } else {
      $filename = rtrim(File::create()->setName($filename), '.pdf') . '.pdf';
      $this->pdf->send($filename);
    }
  }
297682
public function downloadAction()
    {
        if (null === $file = (new CmsFileQuery)->byObject($this->object, $this->objectId)
            ->findPk($this->id)) {
            return '';
        }
        $this->getResponse()->redirectToUrl($file->getUrl());
    }
599775
protected function setBreadcrumbEditDownload()
    {
        $breadcrumbs = array();

        $breadcrumbs[] = array(
            'text' => $this->text('Dashboard'),
            'url' => $this->url('admin')
        );

        $breadcrumbs[] = array(
            'text' => $this->text('Modules'),
            'url' => $this->url('admin/module/list')
        );

        $this->setBreadcrumbs($breadcrumbs);
    }
746289
public function extract() {
        $zip = new ZipArchive();

        $res = $zip->open($this->_sourcePath);
        if ($res === true) {
            $zip->extractTo($this->_workingDir);
            $zip->close();
        } else {
            throw new Exception('Could not open archive ' . $this->_sourcePath);
        }
    }
1091604
private function download($productLineName) {
        $productLineName = str_replace("\"", "", $productLineName);
        if (headers_sent())
            throw new DownloadZipExporterException("could download zip archive");
        header("Content-Type: application/zip");
        header("Content-Disposition: attachment; filename=\"$productLineName.zip\"");
        set_time_limit(0);
        $file = @fopen($this->target, "rb");
        while(!feof($file)) {
            print(@fread($file, 1024*8));
            ob_flush();
            flush();
        }
    }
635112
public function downloadDrupal7()
    {
        ProcessBuilder::create()
            ->setPrefix($this->drushBin)
            ->add('pm-download')
            ->add('drupal-7.38')
            ->add('--destination=' . $this->workingDir)
            ->add('--drupal-project-rename')
            ->add('--yes')
            ->setTimeout(600)
            ->getProcess()
            ->mustRun();
    }
113016
private function download()
    {
        $file = (string) gps('file');

        try {
            $backups = $this->getBackups();
        } catch (Exception $e) {
        }

        if (empty($backups) || !isset($backups[$file])) {
            $this->browser(array(gTxt('rah_backup_can_not_download'), E_ERROR));
            return;
        }

        extract($backups[$file]);

        @ini_set('zlib.output_compression', 'Off');
        @set_time_limit(0);
        @ignore_user_abort(true);

        ob_clean();
        header('Content-Description: File Download');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename="'.$name.'"; size="'.$size.'"');
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: private');
        header('Content-Length: '.$size);
        ob_flush();
        flush();

        if ($f = fopen($path, 'rb')) {
            while(!feof($f) && connection_status() == 0) {
                echo fread($f, 1024*64);
                ob_flush();
                flush();
            }

            fclose($f);
        }

        exit;
    }
374819
public function download(string $file, string $showName = null): void
    {
        $this->handleFile($file, $showName);
    }
1326097
protected function deleteParseFile(){

        if (Yii::$app->session->hasFlash('file_name')) {
            $file_path = Yii::$app->session->getFlash('file_name');
            if(file_exists($file_path))
                unlink($file_path);
        }
    }
736248
protected function generateFilePaths()
    {
        $this->validateStoragePath();

        $path = $this->storagePath . DIRECTORY_SEPARATOR;

        $this->htmlPath = $path . uniqid('pdf-', true).'.html';
        $this->pdfPath = $path . uniqid('html-', true) . '.pdf';
    }
977682
public function actionDownload() {
        /**
         * @var Module $module
         */
        $module = Config::initModule(Module::className());
        $request = Yii::$app->request;
        $type = $request->post('export_filetype', 'html');
        $name = $request->post('export_filename', Yii::t('kvgrid', 'export'));
        $content = $request->post('export_content', Yii::t('kvgrid', 'No data found'));
        $mime = $request->post('export_mime', 'text/plain');
        $encoding = $request->post('export_encoding', 'utf-8');
        $bom = $request->post('export_bom', 1);
        $config = $request->post('export_config', '{}');
        $oldHash = $request->post('export_hash');
        $newData = $name . $mime . $encoding . $bom . $config;
        $security = Yii::$app->security;
        $salt = $module->exportEncryptSalt;
        $newHash = $security->hashData($newData, $salt);
        if (!$security->validateData($oldHash, $salt) || $oldHash !== $newHash) {
            $params = "\nOld Hash:{$oldHash}\nNew Hash:{$newHash}\n";
            throw new InvalidCallException("The parameters for yii2-grid export seem to be tampered. Please retry!{$params}");
        }
        if ($type == GridView::PDF) {
            $config = Json::decode($config);
            $this->generatePDF($content, "{$name}.pdf", $config);
            /** @noinspection PhpInconsistentReturnPointsInspection */
            return;
        } elseif ($type == GridView::HTML) {
            $content = HtmlPurifier::process($content);
        } elseif ($type == GridView::CSV || $type == GridView::TEXT) {
            if ($encoding != 'utf-8') {
                $content = mb_convert_encoding($content, $encoding, 'utf-8');
            } elseif ($bom) {
                $content = chr(239) . chr(187) . chr(191) . $content; // add BOM
            }
        }

        $this->setHttpHeaders($type, $name, $mime, $encoding);
        return $content;
    }
649300
public function snappyPdf()
    {
        /** @var \Barryvdh\Snappy\PdfWrapper $snappy */
        $snappy      = resolve('snappy.pdf.wrapper');
        $options     = config('datatables-buttons.snappy.options');
        $orientation = config('datatables-buttons.snappy.orientation');

        $snappy->setOptions($options)->setOrientation($orientation);

        return $snappy->loadHTML($this->printPreview())->download($this->getFilename() . '.pdf');
    }
1081271
public function listFile()
    {
        $this->downloadFile();
        $this->actionListFile();
        $this->setTitleListFile();
        $this->setBreadcrumbListFile();
        $this->setFilterListFile();
        $this->setPagerListFile();

        $this->setData('files', $this->getListFile());
        $this->setData('entities', $this->file->getEntities());

        $this->outputListFile();
    }