Good morning guys.
In error_log CakePHP is accusing the following:
28/11/2011 10:13:27 Error: [MissingControllerException] ImagesController Controller class could not be found.
# 0 /........./app/webroot/index.php (96): Dispatcher-> dispatch (Object (CakeRequest), Object (CakeResponse))
# 1 {main}
I haven’t idea what it is, because I haven’t ImagesController but have ImagesComponent.
Code snippet:
// app/Controller/BrandsController.php
class BrandsController extends AppController {
public $components = array('Image');
...
public function add() {
if ($this->request->is('post')) {
if (!empty($this->request->data)) {
if(!$this->request->data['Image']['name1']['error']) {
$this->Brand->create();
$image_path = $this->Image->uploadImage(
$this->request->data['Image'],
'Brands',
array(
'folder'=>'upload/imagens/marcas',
'resize'=>175,
'thumb'=>0,
'original'=>false,
'name'=>$this->request->data['Brand']['brand']
)
);
// app/Controller/Component/ImageComponent.php
class ImageComponent extends Component {
public $components = array('String');
function uploadImage($images, $controller, $data) {
$erroimg = false;
$isfile = false;
...
What is the cause of this error?
Sorry for my english
Your error log shows a stack trace with the methods leading to the error. In your case
Dispatcher::dispatchwas called. The docs of this method read:Internally, dispatch will call
Dispatcher::parseParamsto parse the Request to determine the controller to call. If any routes have been configured,parseParamswill apply themIn other words: you requested a URL that the Dispatcher wants to pass on to the Image controller. You don’t have an ImageController and that’s why you get the error. So, add an ImageController or change how CakePHP routes.