Código PHP:
Ver original
require_once(ROOT . DS . 'vendor' . DS . 'ImageTool.php'); use ImageTool; class AdvertisementsController extends AppController{ private function _resizeImage($image,$output){ 'input' => $image, 'output' => $output, 'width' => 100, 'height' => 100, 'keepRatio' => true, )); 'input' => $image, 'output' => $output, 'degrees' => 360 )); return $img; } public function publicadd() { $publicadd = $this->Advertisements->newEntity($this->request->data); if($this->request->is('post')){ $publicadd->id_user = $this->Auth->user('id_user'); $publicadd = $this->Advertisements->patchEntity($publicadd,$this->request->data); if ($this->Advertisements->save($publicadd)) { $id = $publicadd->id_advertisement; $publicaddimg = $this->AdvertisementsImagenes->query(); $images = $this->request->data['name_imagen']; new Folder(WWW_ROOT . 'anuncios/',true,0755); foreach ($images as $image){ $data = [ 'id_advertisement' => $id, 'name_imagen' => $image['name'], ]; $publicaddimg->insert(['id_advertisement','name_imagen','upload_date']) ->values($data); $imgname = $image['tmp_name']; $img = $this->_resizeImage($imgname, WWW_ROOT.'anuncios'.DIRECTORY_SEPARATOR.$publicadd->id_user.DIRECTORY_SEPARATOR.date("Y-m-d").DIRECTORY_SEPARATOR.$image['name']); } $publicaddimg->execute(); $this->Flash->success('Anuncio Publicado'); $this->redirect(['controller' => 'Home','action' => 'index']); }else{ $this->Flash->error('Error al momento de guardar el registro'); } } $this->set('advertisements',$publicadd); $query_categories = $this->Categories->find('list'); $this->set('categories',$query_categories); $query_articles_states = $this->StatesArticles->find('list'); $this->set('states',$query_articles_states); } }
Todo lo hace bien el tema esta que se tarda y antes de agregar el plugin, era rápido por favor ayuda algo mas me debe de faltar