2
votes

I am trying to render images/pdfs that exist outside of my webroot. So this is what I'm doing in my controller to Send the File - as described here. But I'm getting a Fatal Error. Any ideas why and how to fix this? I'm running CakePHP 2.4.5.

$this->autoRender = false;
$path = '/path/to/valid/file.pdf';
$this->response->file($path);
return $this->response;

Fatal error: Call to undefined method Folder::slashTerm()

Stack trace:

  1. {main}() /Path/To/My/htdocs/mysite/app/webroot/index.php:0
  2. Dispatcher->dispatch() /Path/To/My/htdocs/mysite/app/webroot/index.php:96
  3. Dispatcher->_invoke() /Path/To/My/htdocs/mysite/lib/Cake/Routing/Dispatcher.php:160
  4. Controller->invokeAction() /Path/To/My/htdocs/mysite/lib/Cake/Routing/Dispatcher.php:185
  5. ReflectionMethod->invokeArgs() /Path/To/My/htdocs/mysite/lib/Cake/Controller/Controller.php:490
  6. PagesController->load_media() /Path/To/My/htdocs/mysite/lib/Cake/Controller/Controller.php:490
  7. CakeResponse->file() /Path/To/My/htdocs/mysite/app/Controller/PagesController.php:227
  8. File->__construct() /Path/To/My/htdocs/mysite/lib/Cake/Network/CakeResponse.php:1265
  9. File->pwd() /Path/To/My/htdocs/mysite/lib/Cake/Utility/File.php:91
1
I do not have a Model named Folder. I'm using the PagesController here for testing and clarity on this post. It will ultimately live somewhere else. The controller used should have no impact on this Fatal Error - would it? - user3287495
When I do get_class() - it returns "Folder" correctly. However, when I do get_included_files() it returns a big list which includes: /lib/Cake/Utility/File.php but I do not see /lib/Cake/Utility/Folder.php in there. Why would that be? My File.php has App::uses('Folder', 'Utility'); at the top. Weird. - user3287495
What should be enough to solve the problem? When I do this: get_class_methods($this->Folder) it returns an empty array. - user3287495
I think I found the problem. I have a Plugin/Vendor with a class Folder. I think I'm close to getting this resolved. Thanks guys, your input helped me find the problem. - user3287495

1 Answers

1
votes

Problem solved. I had a Plugin that had a class Folder that was taking this over.