123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
-
- namespace SCF\Additionals;
-
- class Download
- {
-
- /**
- * @var string
- */
- private $absolutePath;
-
- /**
- * @var string
- */
- private $fileName;
-
- public function __construct()
- {
-
- }
-
- /**
- * @param string $fileName
- */
- public function setFileName($fileName)
- {
- $this->fileName = $fileName;
- }
-
- /**
- * @return string
- */
- public function getFileName()
- {
- return $this->fileName;
- }
-
- /**
- * @return string
- */
- public function getAbsolutePath()
- {
- return $this->absolutePath;
- }
-
- /**
- * @param string $absolutePath
- */
- public function setAbsolutePath($absolutePath)
- {
- $this->absolutePath = $absolutePath;
- }
-
- public function startDownloadFile()
- {
- $tmpPath = $this->getAbsolutePath();
- $tmpFile = $this->getFileName();
-
- $fh = fopen($tmpPath . $tmpFile, "r");
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header('Content-Description: File Transfer');
- header('Content-Type: application/octed-stream');
- header('Content-Length: ' . @filesize($tmpPath . $tmpFile));
- header("Content-Disposition: attachment; filename=" . $tmpFile);
- header("Content-Transfer-Encoding: binary");
-
- while (true) {
- echo fgets($fh, 4096);
- if (feof($fh)) break;
- if (connection_status() != 0) break;
- }
- fclose($fh);
-
- }
-
- //TODO: Finishing Download Class to generate correct Downloads for Page!
- }
|