php - How to save the name of the image from an input file -
php - How to save the name of the image from an input file -
i have field type string called image_cover on database. have field type file on form:
<?php echo $this->form->create($event, ['type' => 'file']) echo $this->form->file('image_cover') echo $this->form->submit('send') echo $this->form->end() ?> on controller $this->request->data('image_cover') array file name, size etc.
i need value of image_cover alter name of file.
i'm trying on beforesave not working
there few ways of doing this, easiest understand have input field not part of schema of table. example, instead of image_cover have image_file:
echo $this->form->file('image_file'); make sure set image_file in $_accessible list of fields of entity. able access field in beforesave can store it.
there plugin you: https://github.com/davidyell/cakephp3-proffer
php cakephp-3.0
Comments
Post a Comment