Sorry I never got notified of replies for some reason, I will try this looping method I think it could work.
Thanks! On Apr 17, 7:44 am, jeremyharris <funeralm...@gmail.com> wrote: > You could try looping through the files array and saving them manually: > > foreach $_FILES['files'] as $file { > // create data array containing fields such as a foreignKey, model, etc. > and save them as individual records > > } > > Or, instead of using the multiple option, you can try processing them each > as a single request so you don't have to change anything in your controller > but rather just how the view presents it. I've used drag and drop jQuery > plugins and the like to help with this. It's by far my favorite solution, > because it doesn't rely on browser specific features (such as HTML5 > multiple upload). > > > > > > > > On Sunday, April 15, 2012 5:42:25 PM UTC-7, double07 wrote: > > > Hi All, > > > I'm using the cakephp media plugin in my project using the monolithic > > style attachments table, i.e. all the attachments go in the one table > > with foreign_key, model, group etc. saved with the file details. So my > > model looks like: > > > class ProjectProfile extends AppModel { > > > var $name = 'ProjectProfile'; > > var $useDbConfig = 'default'; > > var $useTable = 'project_profiles'; > > var $actsAs = array('Media.Transfer', 'Media.Generator'); > > > public $belongsTo = array( > > 'Project' => array( > > 'className' => 'Project', > > 'foreignKey' => 'pjID' > > ) > > ); > > > var $hasMany = array( > > 'Photo' => array( > > 'className' => 'Media.Attachment', > > 'order' => 'Photo.basename, Photo.id', > > 'foreignKey' => 'foreign_key', > > 'conditions' => array('Photo.model' => 'ProjectProfile', > > 'Photo.group' => 'Photo'), > > 'dependent' => true) > > ); > > > Then a saveAll in the controller when saving my record saves the > > attached file(s). > > > This all works fine, however I'd really like to be able to upload > > multiple files at once, which the plugin does support by doing this in > > the form: > > > echo $this->Form->hidden('Photo.0.model', array('value' => 'Photo')); > > echo $this->Form->input('Photo.0.file', array('type' => 'file'); > > echo $this->Form->hidden('Photo.1.model', array('value' => 'Photo')); > > echo $this->Form->input('Photo.1.file', array('type' => 'file'); > > echo $this->Form->hidden('Photo.2.model', array('value' => 'Photo')); > > echo $this->Form->input('Photo.2.file', array('type' => 'file'); > > > But I think you'd agree that's a bit cumbersome to have to click > > browse for each individual file. The simplist method I could see to to > > allow multiple file uploads was to use the HTML5 multiple file section > > option - > >http://bakery.cakephp.org/articles/veganista/2012/01/31/html_5_multip... > > : > > > echo $this->Form->input('files.', array('type' => 'file', > > 'multiple')); > > > This allows you to shift click in the file browser to select multiple > > files then puts the files into an array to save... however, this field > > format isn't handled by the media plugin. Also, there'd be no way to > > add the model, group etc. fields on the save as far as I could see. > > > So, does anybody know how I can handle multi file uploads with the > > media plugin using the monolithic model? I'm open to all suggestions. > > > Thanks in advance. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php