El problema es que tengo 4 fileinputs para subir archivos de imagen a la 
base de datos. El problema es que si no selecciono las 4 imagenes no se 
crea el directorio donde se guardan las fotos. Si me pueden ayudar con 
alguna idea se los agradezco mucho.

Soy nuevo en cakephp y poco a poco le voy tomando el modo.


Modelo:

class Anuncio extends AppModel {

    public $actsAs = array(
        'Upload.Upload' => array(
                'foto',
'foto1',
'foto2',
                        'foto3' => array(
                'fields' => array(
                    'dir' => 'foto_dir'
                 )
            )
        )
    );

Controller:


  public function vender() {
        if ($this->request->is('post')) {
            $this->Anuncio->create();
            if ($this->Anuncio->saveAll($this->request->data)) {
                $this->Session->setFlash(__('Su anuncio se ha guardado con 
exito!.'));
                return $this->redirect(array('action' => 'ver'));
            }
            $this->Session->setFlash(__('No se pudo guardar su anuncio.'));
        }
    }



Formulario:


<?php

echo $this->Form->create('Anuncio',array('type' => 'file'));

echo $this->Form->input('Título');
echo '<br>';
echo $this->Form->input('Descripción');
echo '<br>';
echo $this->Form->input('Precio');
echo '<br>';
echo $this->Form->input('Cantidad');
echo '<br>';
echo $this->Form->input('Email');
echo '<br>';
echo $this->Form->input('Teléfono');
echo '<br>';
echo $this->Form->input('Anuncio.foto', array('type' => 'file')); 
echo '<br>';
echo $this->Form->input('Anuncio.foto1', array('type' => 'file')); 
echo '<br>';
echo $this->Form->input('Anuncio.foto2', array('type' => 'file')); 
echo '<br>';
echo $this->Form->input('Anuncio.foto3', array('type' => 'file')); 
echo '<br>';
echo $this->Form->input('foto_dir', array('type' => 'hidden')); 
echo '<br>';
echo $this->Form->end('Guardar');
?>











-- 
Has recibido este mensaje porque estás suscrito al grupo "CakePHP-es" de Grupos 
de Google.
Para anular la suscripción a este grupo y dejar de recibir sus mensajes, envía 
un correo electrónico a cakephp-es+unsubscr...@googlegroups.com.
Para publicar una entrada en este grupo, envía un correo electrónico a 
cakephp-es@googlegroups.com.
Visita este grupo en http://groups.google.com/group/cakephp-es.
Para obtener más opciones, visita https://groups.google.com/d/optout.

Responder a