CakePHP change a view to have an image upload field in it

Written by James McDonald

October 18, 2011

# add array('type'=>'file') to the Form->create method
< ?php echo $this->Form->create('Map', array('type'=>'file'));?>
< ?php __('Add Map'); ?> < ?php # most fields are just normal automagic text/numeric/boolean fields echo $this->Form->input('name'); echo $this->Form->input('locality'); echo $this->Form->input('suburb_id'); echo $this->Form->input('map_type_id'); # change the field you want to become the upload field to have a file type # if you want a label you also need # if you are changing a field you need to change the model too # because it passes an array to cakephp echo $this->Form->input('upload', array( 'type' => 'file', 'label' => "XCF File")); echo $this->Form->input('source_image'); echo $this->Form->input('thumb_image'); echo $this->Form->input('tiled_image'); echo $this->Form->input('division_id'); echo $this->Form->input('dir'); echo $this->Form->input('mimetype'); echo $this->Form->input('filesize'); echo $this->Form->input('active'); ?>
< ?php echo $this->Form->end(__('Submit', true));?>


Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

Toggen builds a new website

So I have built and hosted a new website for Roger Clark Pest Management they are a family owned and operated Pest...


Just downloaded WizTree (not a sponsor) from It seems to do what it says on the tin which is...

Scam call from “Telstra”

Just had a call from a man with a sub-continental accent from caller ID 0734946596 Told me there was problem with my...