Make sure your /app/files directory is writable by the webserver.
Replace MODEL_FIELD_NAME in the following with the field that you want
to store your image filenames as. eg. filename or image etc.

In your model you need to have

var $actsAs = array('Upload' => array(
                'MODEL_FIELD_NAME' => array(
                        'dir' => 'files/Image',
                        'overwrite_existing' => true,
                        'create_directory' => true,
                        'allowed_mime' => array('image/jpeg', 'image/
pjpeg', 'image/gif', 'image/png'),
                        'allowed_ext' => array('.jpg', '.jpeg',
'.png', '.gif'))
                ) ;

In your database you need a MODEL_FIELD_NAME field.  In your view use
$form->file("Model.MODEL_FIELD_NAME");

The controller needs

var $helpers = array("Form"); // plus any others you need eg.
Javascript, Html

The action does not need to do anything special as the behaviour
automatically does it the file movimg, filename filtering etc.

To display the uploaded file in your views you can use
HtmlHelper::Image 
http://api.cakephp.org/1.2/class_html_helper.html#4dff64fa3c411bac6bf9c8950db7ea28

On Jun 13, 2:30 pm, Allen Romero <[EMAIL PROTECTED]> wrote:
> I realize those instructions are obvious for the experts, but I'm
> still a newbie.
>
> I built my table.
> Created my behavior and model.
>
> I'm just not sure how to implement it in my controller and view. Make
> sense?
>
> On Jun 12, 9:22 pm, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
> >http://bakery.cakephp.org/articles/view/improved-upload-behaviour-wit...
>
> > On Jun 13, 1:29 pm, Allen Romero <[EMAIL PROTECTED]> wrote:
>
> > > Is there an example of how to use the 'upload behavior' that was
> > > created?
>
> > > I downloaded it but am clueless on how to actually use it in my
> > > controller.  Haven't yet grasped using behaviors.
>
> > > Thanks in advance.
>
> > > Allen


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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