I'm trying to make my for
rotate according to how many images are 'entered' in SELECT. The problem is that regardless of how many images are 'inputted', it only saves the first one. What is wrong with this logic?
private function criarfoto($galeria_id, $file) {
$extension = "";
$valores = count($file['Foto']); // SALVA em quantidade,os indices que tem dentro do array.
for ($i = 0; $i < $valores; $i++) { // faz o loop de acordo com a quantidade de indices no array
$extension = pathinfo($file['Foto'][$i]['name'], PATHINFO_EXTENSION);
$allowExt = array('jpg', 'jpeg', 'png', 'gif');
//print_r($file);
if (!in_array($extension, $allowExt)) {
return false;
}
$fotos_galeria = array(
'galeria_id' => $galeria_id,
'titulo' => $file['titulo'],
'descricao' => $file['descricao'],
'extension' => $extension,
);
$this->Foto->create();
if ($this->Foto->save(array('Foto' => $fotos_galeria))) {
//die(print_r($fotos_galeria));
$foto_id = $this->Foto->id;
if (move_uploaded_file($file['Foto'][$i]['tmp_name'], WWW_ROOT . 'files' . DS . 'galeria' . DS . "{$foto_id}_o.{$extension}")) {
return $foto_id;
} else {
return false;
}
} else {
return false;
}
}
}