Hey Rajesh,
The best way is to use the normal PHP method. So here is how I would
do it, it is just a small example, but it does do what you want.
Your form:
<form enctype="multipart/form-data" action="<?php echo $html->url('/
admin/profile/add'); ?>" method="post">
<?php echo $form->labelTag('Profile/username', 'Category');?>
<?php echo $html->input('Profile/username');?>
<?php echo $html->tagErrorMsg('Profile/username', 'A username for the
profile is required') ?>
<label for="img">Image</label>
<input type="file" name="image" id="img" size="60" />
</form>
Now for the controller code:
$id = $this->Profile->getLastInsertId();
if (!empty($this->params['form']['image']))
{
$upload_dir = WWW_ROOT.'/img/properties/'.$id.'/';
if (!is_dir($upload_dir))
{
mkdir($upload_dir);
}
$upload_file = $upload_dir . basename($this->params['form']['image']
['name']);
move_uploaded_file($this->params['form']['image']['tmp_name'],
$upload_file);
}
There is a bit of filesystem management going on there, but the main
thing is the $this->params['form']['image'] array. The above would go
in the if conditional where you save the data, ie:
if ($this->Profile->save($this->data)) {
[...]
}
Hope this helps
Shaun
On Oct 25, 1:09 pm, Rajesh <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am new to cake PHP and i am using version 1.1.17. I am little
> confused as to how to handle image uploads within a single form that
> has other fields to capture additional information, for example
> contact info and i have 2 seperate models (contact and image).
>
> Could someone please let me know how do i implement this
> functionality.
>
> Thanks
> Rajesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---