本文整理汇总了PHP中CakeResponse::file方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeResponse::file方法的具体用法?PHP CakeResponse::file怎么用?PHP CakeResponse::file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeResponse
的用法示例。
在下文中一共展示了CakeResponse::file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _deliverMedia
protected function _deliverMedia(CakeResponse $response, $mediaFile, $mediaInfo)
{
$response->sharable(true, 2592000);
//$response->mustRevalidate(true);
$response->expires('+30 days');
$modTime = filemtime($mediaFile);
$response->modified($modTime);
$response->etag(md5($mediaFile . $modTime));
//$response->header("Pragma", "cache");
$response->type($mediaInfo['ext']);
$response->file($mediaFile);
$response->send();
}
示例2: testFileNotFound
/**
* testFileNotFound
*
* @expectedException NotFoundException
* @return void
*/
public function testFileNotFound()
{
$response = new CakeResponse();
$response->file('/some/missing/folder/file.jpg');
}
示例3: testFileWithPathTraversal
/**
* test file with ..
*
* @expectedException NotFoundException
* @return void
*/
public function testFileWithPathTraversal()
{
$response = new CakeResponse();
$response->file('my/../cat.gif');
}
示例4: testFileWithDotsInFilename
/**
* Although unlikely, a file may contain dots in its filename.
* This should be allowed, as long as the dots doesn't specify a path (../ or ..\)
*
* @expectedException NotFoundException
* @execptedExceptionMessageRegExp #The requested file .+my/Some..cat.gif was not found or not readable#
* @return void
*/
public function testFileWithDotsInFilename()
{
$response = new CakeResponse();
$response->file('my/Some..cat.gif');
}
示例5: download
/**
* ダウンロード
*
* @param string $filename ダウンロード時のファイル名
* @return CakeResponse
*/
public function download($filename)
{
$response = new CakeResponse();
$response->type('text/csv');
$response->file($this->path, ['name' => $filename, 'download' => 'true']);
return $response;
}
示例6: download
/**
* Download
*
* @param string $filename download時のファイル名
* @return CakeResponse ダウンロードレスポンス
*/
public function download($filename)
{
// closeされてなかったらcloseする
if ($this->_open) {
$this->close();
}
$response = new CakeResponse();
$response->type('application/zip');
$response->file($this->path, ['name' => $filename, 'download' => 'true']);
return $response;
}