Cakephp 2.0 Tip# 14 File Uploads

cake-logo

Firstly you need to install the Plugin;
https://github.com/josegonzalez/cakephp-upload

In the Model of the object you want to allow uploads to(eg User,Product) add;

Model

public $actsAs = array(
        'Upload.Upload' => array(
            'picture'
        )
);

View:

In the View Form of this action add;

Form->create('User', array('type' => 'file')); ?>
Form->input('picture',array('type' => 'file','accept'=>'image/*')); ?>
Form->end(__('Submit')); ?>