我正在尝试渲染我的webroot之外的图像/ pdf。所以这就是我在控制器中执行发送文件的过程 - 如here所述。但我得到致命错误。任何想法为什么以及如何解决这个问题?我正在运行CakePHP 2.4.5。
$this->autoRender = false;
$path = '/path/to/valid/file.pdf';
$this->response->file($path);
return $this->response;
致命错误:调用未定义的方法Folder :: slashTerm()
堆栈追踪:
- {main}()/ Path/To/My/htdocs/mysite/app/webroot/index.php:0
- Dispatcher-> dispatch()/ Path/To/My/htdocs/mysite/app/webroot/index.php:96
- Dispatcher-> _invoke()/ Path/To/My/htdocs/mysite/lib/Cake/Routing/Dispatcher.php:160
- Controller-> invokeAction()/ Path/To/My/htdocs/mysite/lib/Cake/Routing/Dispatcher.php:185
- ReflectionMethod-> invokeArgs()/ Path/To/My/htdocs/mysite/lib/Cake/Controller/Controller.php:490
- PagesController-> load_media()/ path/To/My/htdocs/mysite/lib/Cake/Controller/Controller.php:490
- CakeResponse-> file()/ Path/To/My/htdocs/mysite/app/Controller/PagesController.php:227
- 文件 - > __ construct()/ Path/To/My/htdocs/mysite/lib/Cake/Network/CakeResponse.php:1265
- 文件 - > pwd()/ Path/To/My/htdocs/mysite/lib/Cake/Utility/File.php:91
醇>