Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple file upload #14

Closed
victorlap opened this issue Apr 24, 2012 · 0 comments
Closed

multiple file upload #14

victorlap opened this issue Apr 24, 2012 · 0 comments

Comments

@victorlap
Copy link

Hello,

You did a great job when writing this plugin, but i do have an issue.
I've got multiple file upload fields in my form.
But the user don't have to fill them all.
Your script is making a record though for every one of this file.
How can i solve this?

code:
add.ctp -- Portfolio / add

Form->create('Portfolio', array('type' => 'file')); echo $this->Form->input('Portfolio.title', array('label' => 'Titel')); echo $this->Form->input('Photo.0.description', array('label' => 'Beschrijving')); echo $this->Form->input('Photo.0.photo', array('type' => 'file', 'label' => 'Foto')); echo $this->Form->input('Photo.1.description', array('label' => 'Beschrijving')); echo $this->Form->input('Photo.1.photo', array('type' => 'file', 'label' => 'Foto')); echo $this->Form->end('Voeg item toe'); ?>

PortfolioController.php -- Portfolio Controller

request->is('post')) { if($this->Portfolio->saveAssociated($this->request->data)) { $this->Session->setFlash('Het portfolio item is toegevoegd.'); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash('Het portfolio item kon niet worden toegevoegd.'); } debug($this->request->data); debug($_FILES); } } ?>

Photo.php -- Photo Model

array( 'photo' => array( 'styles' => array( 'thumb' => '223x112' ), 'path' => ':webroot/img/portfolio/:basename_:style.:extension', 'default_url' => ':webroot/img/portfolio/600x300.gif' ) ) ); public $validate = array( 'photo' => array( 'maxSize' => array( 'rule' => array('attachmentMaxSize', 10485760), 'message' => 'Foto kan niet groter zijn dan 10MB' ) ) ); ``` } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant