Maybe $data is being changed.

$this->log($this->data);

if($this->Image->upload($this->data)) {
   $this->Session->setFlash('The image was successfully uploaded.');

   $this->log($this->data);
}


On Mar 7, 7:50 am, mattyh88 <[email protected]> wrote:
> I've just noticed that, when I put the first "if" (for the image
> upload) in comments, then the Image->save does work. The image
> successfully gets inserted. It just doesn't work when the first
> "if" (for the image upload) isn't commented. So basically, why does
> CakePhp skip my Image->save() (after successfully uploading the image
> to the webserver)
>
> On 7 mrt, 11:14, mattyh88 <[email protected]> wrote:
>
> > I've been trying to save some details of my image to the database.
> > This is what I'm doing: (the upload works, but image-name and image-
> > album_id don't get inserted in the database)
>
> > Form:
> > <?php
> >     echo $form->create('Image', array('type' => 'file', 'action' =>
> > 'upload'));
>
> >     echo $form->label('image', 'Upload image: ');
> >     echo $form->file('image');
> >     echo $form->input('album_id');
> >     echo $form->end('Upload');
> > ?>
>
> > Upload function in images_controller:
> > function upload() {
> >         if (!empty($this->data)) {
> >             // Upload an image
> >             if($this->Image->upload($this->data)) {
> >                 $this->Session->setFlash('The image was successfully
> > uploaded.');
> >             }
>
> >            // Insert image data into database
> >            $this->data['Image']['name'] = $this->data['Image']['image']
> > ['name'];
> >            if($this->Image->save($this->data)) {
> >                 debug($this->data);die;
> >                 $this->Session->setFlash('Your image has been saved.');
> >             }
>
> >             else {
> >                 $this->Session->setFlash('There was an error with the
> > uploaded file.');
> >             }
>
> >             $this->redirect(array('action' => 'index'));
> >         }
>
> > }
>
> > Thanks in advance,
> > mattyh88
>
>

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