コード例 #1
0
ファイル: download.php プロジェクト: sachintaware/phpsec
 /**
  * Serve some data to the client
  * @param String $Data
  * @param String $OutputFilename
  * @return boolean
  */
 public static function serveData($Data, $OutputFilename)
 {
     $Filename = $OutputFilename;
     header("Content-type: " . DownloadManager::MIME($Filename));
     //get the file type.
     header('Content-disposition: attachment; filename=' . $Filename);
     //add attachment; here to force download
     header('Content-length: ' . strlen($Data));
     //specify the browser the length of data it must expect.
     echof($Data);
     flush();
     return true;
 }
コード例 #2
0
ファイル: DownloadTest.php プロジェクト: sachintaware/phpsec
 /**
  * Function to test if we are able to determine the correct file type.
  */
 public function testMIME()
 {
     $type = DownloadManager::MIME("myTestFile.bmp");
     $this->assertSame('image/bmp', $type);
 }