Public feed
#722738
function consolidar(){ if (empty($this->data)) { $this->render(); } else { if (!empty($this->params['form'])) { $web_destino=$_SERVER['DOCUMENT_ROOT'].DS.'app/webroot/img/galeria'.DS.$this->data['Galeria']['web']; $web_origen=$_SERVER['DOCUMENT_ROOT'].DS.'app/webroot/img/galeria'.DS.'upload'.DS.$this->data['Galeria']['web']; if ($handle = opendir($web_origen)) { $this->Galeria->execute('delete from galerias where web like \''.$this->data['Galeria']['web'].'\''); $id_ultimo=$this->Galeria->ultimo_id(); while ($fichero = readdir($handle)) { if ($fichero!=='.' and $fichero!=='..'){ $id_ultimo+=1; $fichero_final=$this->data['Galeria']['web'].'.'.$id_ultimo.'.jpg'; if (!copy($web_origen.DS.$fichero, $web_destino .DS.$fichero_final )) { $this->Flash('Falló el renombrado del fichero.','ver'.DS.$this->data['Galeria']['web']); }else{ //Actualizacion de la base de datos. $this->data['Galeria']['nombre']=$fichero_final; $this->data['Galeria']['web']=$this->data['Galeria']['web']; if (!$this->Galeria->save($this->data)){ $this->Session->Flash('Falló la actualizacion de la base de datos'); } } } } } } } }