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