Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/06/2015, 21:09
Avatar de detective_jd
detective_jd
 
Fecha de Ingreso: abril-2011
Ubicación: Salto
Mensajes: 437
Antigüedad: 13 años
Puntos: 6
Subir Imagenes en CakePhp 2.6

Hola a todos, quería hacerles una consulta, estoy tratando de subir imagenes para un proyecto que me pidieron, y este es mi código:

public function add() {
if ($this->request->is('post')) {
//Subir imagenes
if ($this->data['Aparato']['id_foto']) {
$file = new File($this->request->data['Aparato']['id_foto']['tmp_name'], true, 0644);
$path_parts = pathinfo($this->data['Aparato']['id_foto']['name']);
$ext = $path_parts['extension'];
if ($ext != 'jpg' && $ext != 'jpeg' && $ext != 'gif' && $ext != 'png') {
$this->Session->setFlash('Solo puedes subir imagenes.');
$this->render();
}
else {
$date = $this->request->data['Aparato']['id_foto']['name'];
$filename =$date.'-post-image.'.$ext;
$data = $file->read();
$file->close();
$file = new File(WWW_ROOT.'/img/'.$filename,true);
$file->write($data);
$file->close();
}
}
//Fin subir imagenes
$this->data['Aparato']['id_foto'] = $this->data['Aparato']['id_foto']['name'];
$this->Aparato->create();
if ($this->Aparato->save($this->request->data)) {
$this->Session->setFlash(__('Aparato Guardado'));
$this->redirect(array('action' => 'index'));
}
else {
$this->Session->setFlash(__('error al crear aparato'));
}
}
}

Por alguna razón no me guarda el aparato en la bd, y me da el sgtes errores:

Error: The application is trying to load a file from the Upload plugin

Error: Make sure your plugin Upload is in the app/Plugin directory and was loaded

<?php
CakePlugin::load('Upload');

Loading all plugins: If you wish to load all plugins at once, use the following line in your app/Config/bootstrap.php file

CakePlugin::loadAll();
Notice: If you want to customize this error message, create app/View/Errors/missing_plugin.ctp



Cómo verán no sé que hacer, cualquier respuesta la agradeceré. Saludos y espero respuestas