Here it goes!
In $this->data there is nothing!! I mean the file upload array doesn't
exist!

This is my view

<?php

        $hidden=false;

        if ($this->params['action'] == 'admin_add') { $postUrl = '/admin/
canciones/add'; }

        elseif ($this->params['action'] == 'admin_edit'){ $postUrl = '/admin/
canciones/edit/'.$this->data['Cancion']['id'];$hidden = true; }

?>

<div class="standard-form">

        <?php

                echo $form->create('Cancion', array('type' => 'file', 'url' =>
$postUrl));

                echo $form->input('nombre', array('label' => 'Nombre',
'class' => 'required','escape' => false, 'size' => 50));
                echo "<div class=\"input text\"><strong>Habilitar Emision</
strong>";echo $form->checkbox('habilitada');echo '</div>';

                echo $form->hidden('parent_id');
                echo $form->input('archivo', array('type' => 'file', 'label' =>
'Archivo (debe ser mp3)'));

                if ($hidden) {

                        echo $form->hidden('id');

                }



                ?>
        <div class="submit form-bottom">

            <input type="submit" value="Guardar" >

            <span class="edit-actions"> or

                        <?php echo $html->link('Cancelar', array('admin' => 
true, 'action'
=> 'index', 'controller' =>'canciones'), array('class' => 'cancel')); ?
>

            </span>

        </div>

        </form>

</div>


And here i put the controller thing...
This function upload the file

        private function procesarArchivos($modelName, $campoArchivos) {



                $this->FileUpload->fileModel = $modelName;



                foreach($campoArchivos as $campo) {

                        if (!empty($this->data[$modelName][$campo]['name'])) {

                                $this->FileUpload->fileVar = $campo;

                                $this->FileUpload->uploadedFile = 
$this->data[$modelName][$campo];

                                $this->FileUpload->fileName = 
$this->data[$modelName]
['nombre']; // nombre del archivo SIN la extension

                                $this->FileUpload->processFile();

                                if ($this->FileUpload->success) {

                                        $this->data[$modelName][$campo] = 
$this->FileUpload->finalFile;



                                        $arch = $this->FileUpload->finalFile;

                                        $ext = strrchr($arch,".");

                                }

                                else {

                                        unset ($this->data[$modelName][$campo]);

                                }

                        }

                        else {

                                unset ($this->data[$modelName][$campo]);

                        }

                }

        }



And this function is called by the admin add function, and then call
the above one

        private function processCancionForm() {



                $modelName = 'Cancion';

                $campoArchivos = array('archivo');

                $this->procesarArchivos($modelName, $campoArchivos);



                if ($this->Cancion->save($this->data)) {

                        $this->redirect('/admin/canciones/index');

                }

        }



Thank you!!


On Dec 27, 7:53 pm, cricket <[email protected]> wrote:
> On Mon, Dec 27, 2010 at 7:10 AM, Leandro Montero <[email protected]> wrote:
> > So.......nothing to say??????
>
> Well, what have you done to debug the problem? Have you checked the
> logs (both Cake's and Apache's)? Have you debugged $this->data? Does
> the file upload array exist? If so, what error value is there? What
> about your code? Will you post the form here? Did you pass 'type' =>
> 'file' to $this->Form->create()?
>
> There are many things people could say but we'll likely find the
> solution soonest if you fill us in on the situation a bit clearer.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to