milesj / uploader

[Deprecated] A CakePHP plugin for file uploading and validating.
MIT License
193 stars 73 forks source link

Issue with multiple files upload #4

Closed srumjant closed 14 years ago

srumjant commented 14 years ago

The problem is that I can't upload multiple files. 1 should be image file and second one pdf file.

Configuration

actsAs in model var $actsAs = array( 'Uploader.FileValidation' => array( 'image' => array( 'extension' => array('gif', 'jpg', 'png', 'jpeg'), 'filesize' => 2097152, 'optional' => true ), 'pdf' => array( 'extension' => array('pdf'), 'filesize' => 5242880, 'optional' => true ) ) );

controller code if ($data = $this->Uploader->uploadAll()) { $this->Session->setFlash(__('File Added.', true), true); }

view <?=$form->create('Product');?> <?=$form->input('image', array('type' => 'file', 'label' => ('Image File', true)));?> <?=$form->input('pdf', array('type' => 'file', 'label' => ('Pdf File', true)));?> <?=$form->end('Upload');?>

Is is uploading and validating image file, but just ignores pdf file.

jrevillini commented 14 years ago

Your problem must have something to do with the validation routine, because I'm successfully uploading multiple JPGs and PDFs in a single model saveAll call without issue, but I didn't use the FileValidation parameter. Try getting rid of validation so you can upload anything and see if that works. If nothing else, it narrows down where the bug is if it's not with your code.

Here's my $actsAs member variable of my Attachment model: var $actsAs = array( 'Uploader.Attachment' => array( 'file' => array( 'uploadDir' => '/files/uploads/', // Where to upload to, relative to app webroot 'dbColumn' => 'path', // The database column name to save the path to 'maxNameLength' => 255, // Max file name length 'overwrite' => false, // Overwrite file with same name if it exists 'name' => '', // The name to give the file (should be done right before a save) 'transforms' => array() // What transformations to do on images: scale, resize, etc ) ),

);
milesj commented 14 years ago

I was able to upload multiple images as well as validate. You must have something incorrect in your code.