Re: Multiple Uploads with MeioUpload

2009-01-28 Thread Flipflops

No worries. Glad to help.

John

On Jan 28, 3:06 pm, "Arak Tai'Roth"  wrote:
> Perfect, this is exactly what I was hoping for. Thank you very much
> for your help with this.
>
> On Jan 28, 8:43 am, Flipflops  wrote:
>
> > Hi
>
> > Well you can include a seperate field in your model for each upload,
> > something like filename1, filename2 etc. - and thinking about it this
> > does work with saveAll - but I needed felxibility and the advantage of
> > having a seperate model just for uploads is you get to store all the
> > meta data too...
>
> > So only one instance of meio - in the upload model.
>
> > I have:
>
> > class Upload extends AppModel {
>
> >         var $name = 'Upload';
>
> >         /* use the upload compaonent */
> >         var $actsAs = array(
> >                 'Polymorphic',
> >                 'MeioUpload' => array(
> >                         'filename' => array(
> >                                 'dir' => 'img{DS}{model}{DS}{field}',
> >                                 'create_directory' => true,
> >                                 'allowed_mime' => array('image/jpeg', 
> > 'image/pjpeg', 'image/png',
> > 'application/pdf', 'image/gif'),
> >                                 'allowed_ext' => array('.jpg', '.jpeg', 
> > '.png', '.pdf', '.gif'),
> >                                 'thumbsizes' => array(
> >                                         'small'  => array('width'=>60, 
> > 'height'=>60, 'image_options' =>
> > array('zc' => 1)),
> >                         'medium' => array('width'=>220, 'height'=>220),
> >                         'large'  => array('width'=>800, 'height'=>600)
> >                                 )
> >                                 /*'default' => 'default.jpg',*/
> >                         )
> >                 )
> >         );
>
> > }
>
> > and
>
> > class Product extends AppModel {
>
> >         var $name = 'Product';
>
> >         var $hasMany = array(
> >         'Upload' => array(
> >             'className' => 'Upload',
> >             'foreignKey' => 'foreign_id',
> >             'conditions' => array('Upload.class' => 'Product'),
> >             'dependent' => true
> >         )
> >     );
>
> > }
>
> > John
>
> > On Jan 28, 2:11 pm, "Arak Tai'Roth"  wrote:
>
> > > That should help actually, as I am also using a seperate table to hold
> > > the images and then using associations to link them together. I am
> > > wondering though, how is your model coded to handle this, is it the
> > > same as it is for one image, or do you have to include a seperate
> > > entry of MeioUpload for each file input you have on your view form?
>
> > > On Jan 28, 8:04 am, Flipflops  wrote:
>
> > > > Hi
>
> > > > I'm using MeioUpload for a current project with multiple images. It is
> > > > a bit more complicated as I'm saving all the images into a single
> > > > table using a ploymorphic association (ie. Product hasMany Upload,
> > > > Profile hasOne Upload etc.) - but this should be helpful anyway
>
> > > > The upload fields generated in the view are organised like so:
>
> > > > 
> > > >         Filename
> > > >          > > > id="Upload1Filename" />
> > > > 
> > > > 
> > > >         Filename
> > > >          > > > id="Upload2Filename" />
> > > > 
>
> > > > etc.
>
> > > > For whatever reasons - probably the polymorphic association - I never
> > > > got this to work with saveAll, but anyway I have a bit of code to
> > > > upload / save the images uploaded from which ever model in
> > > > app_controller like this: (simplified example)
>
> > > > function upload_something($id = null) {
> > > >                 // id is the primary key of the parent model e.g Product
> > > >                 // e.g. Product hasMany Uploads
> > > >                 if (!$id) {
> > > >                         $this->flash(__('Invalid ' . $this->modelClass, 
> > > > true), array
> > > > ('action'=>'admin_index'));
> > > >                 }
>
> > > >                 if(!empty($this->data)){
>
> > > >                         if(isset($this->data['Upload'])){
>
> > > >                                 $upload_errors = array();
>
> > > >                                 foreach($this->data['Upload'] as 
> > > > $Upload => $value){
>
> > > >                                                         // only process 
> > > > the upload if it has actually been uploaded
> > > >                                                         
> > > > if(!empty($value['filename']['name'])){
>
> > > >                                                                 
> > > > $this->{$this->modelClass}->Upload->create();
>
> > > >                                                                 
> > > > $value['class'] = $this->modelClass;
> > > >                                                                 
> > > > $value['foreign_id'] = $id;
> > > >                                                                 
> > > > $this->{$this->modelClass}->Upload->save($value);
>
> > > >                                               

Re: Multiple Uploads with MeioUpload

2009-01-28 Thread Arak Tai'Roth

Perfect, this is exactly what I was hoping for. Thank you very much
for your help with this.

On Jan 28, 8:43 am, Flipflops  wrote:
> Hi
>
> Well you can include a seperate field in your model for each upload,
> something like filename1, filename2 etc. - and thinking about it this
> does work with saveAll - but I needed felxibility and the advantage of
> having a seperate model just for uploads is you get to store all the
> meta data too...
>
> So only one instance of meio - in the upload model.
>
> I have:
>
> class Upload extends AppModel {
>
>         var $name = 'Upload';
>
>         /* use the upload compaonent */
>         var $actsAs = array(
>                 'Polymorphic',
>                 'MeioUpload' => array(
>                         'filename' => array(
>                                 'dir' => 'img{DS}{model}{DS}{field}',
>                                 'create_directory' => true,
>                                 'allowed_mime' => array('image/jpeg', 
> 'image/pjpeg', 'image/png',
> 'application/pdf', 'image/gif'),
>                                 'allowed_ext' => array('.jpg', '.jpeg', 
> '.png', '.pdf', '.gif'),
>                                 'thumbsizes' => array(
>                                         'small'  => array('width'=>60, 
> 'height'=>60, 'image_options' =>
> array('zc' => 1)),
>                         'medium' => array('width'=>220, 'height'=>220),
>                         'large'  => array('width'=>800, 'height'=>600)
>                                 )
>                                 /*'default' => 'default.jpg',*/
>                         )
>                 )
>         );
>
> }
>
> and
>
> class Product extends AppModel {
>
>         var $name = 'Product';
>
>         var $hasMany = array(
>         'Upload' => array(
>             'className' => 'Upload',
>             'foreignKey' => 'foreign_id',
>             'conditions' => array('Upload.class' => 'Product'),
>             'dependent' => true
>         )
>     );
>
> }
>
> John
>
> On Jan 28, 2:11 pm, "Arak Tai'Roth"  wrote:
>
> > That should help actually, as I am also using a seperate table to hold
> > the images and then using associations to link them together. I am
> > wondering though, how is your model coded to handle this, is it the
> > same as it is for one image, or do you have to include a seperate
> > entry of MeioUpload for each file input you have on your view form?
>
> > On Jan 28, 8:04 am, Flipflops  wrote:
>
> > > Hi
>
> > > I'm using MeioUpload for a current project with multiple images. It is
> > > a bit more complicated as I'm saving all the images into a single
> > > table using a ploymorphic association (ie. Product hasMany Upload,
> > > Profile hasOne Upload etc.) - but this should be helpful anyway
>
> > > The upload fields generated in the view are organised like so:
>
> > > 
> > >         Filename
> > >          > > id="Upload1Filename" />
> > > 
> > > 
> > >         Filename
> > >          > > id="Upload2Filename" />
> > > 
>
> > > etc.
>
> > > For whatever reasons - probably the polymorphic association - I never
> > > got this to work with saveAll, but anyway I have a bit of code to
> > > upload / save the images uploaded from which ever model in
> > > app_controller like this: (simplified example)
>
> > > function upload_something($id = null) {
> > >                 // id is the primary key of the parent model e.g Product
> > >                 // e.g. Product hasMany Uploads
> > >                 if (!$id) {
> > >                         $this->flash(__('Invalid ' . $this->modelClass, 
> > > true), array
> > > ('action'=>'admin_index'));
> > >                 }
>
> > >                 if(!empty($this->data)){
>
> > >                         if(isset($this->data['Upload'])){
>
> > >                                 $upload_errors = array();
>
> > >                                 foreach($this->data['Upload'] as $Upload 
> > > => $value){
>
> > >                                                         // only process 
> > > the upload if it has actually been uploaded
> > >                                                         
> > > if(!empty($value['filename']['name'])){
>
> > >                                                                 
> > > $this->{$this->modelClass}->Upload->create();
>
> > >                                                                 
> > > $value['class'] = $this->modelClass;
> > >                                                                 
> > > $value['foreign_id'] = $id;
> > >                                                                 
> > > $this->{$this->modelClass}->Upload->save($value);
>
> > >                                                                 
> > > if(!empty($this->{$this->modelClass}->Upload->validationErrors)){
>
> > >                                                                         
> > > $upload_errors[$Upload]['filename'] =  
> > > $this->{$this->modelClass}->Upload->validationErrors['filename']

Re: Multiple Uploads with MeioUpload

2009-01-28 Thread Flipflops

Hi

Well you can include a seperate field in your model for each upload,
something like filename1, filename2 etc. - and thinking about it this
does work with saveAll - but I needed felxibility and the advantage of
having a seperate model just for uploads is you get to store all the
meta data too...

So only one instance of meio - in the upload model.

I have:


class Upload extends AppModel {

var $name = 'Upload';



/* use the upload compaonent */
var $actsAs = array(
'Polymorphic',
'MeioUpload' => array(
'filename' => array(
'dir' => 'img{DS}{model}{DS}{field}',
'create_directory' => true,
'allowed_mime' => array('image/jpeg', 
'image/pjpeg', 'image/png',
'application/pdf', 'image/gif'),
'allowed_ext' => array('.jpg', '.jpeg', '.png', 
'.pdf', '.gif'),
'thumbsizes' => array(
'small'  => array('width'=>60, 
'height'=>60, 'image_options' =>
array('zc' => 1)),
'medium' => array('width'=>220, 'height'=>220),
'large'  => array('width'=>800, 'height'=>600)
)
/*'default' => 'default.jpg',*/
)
)
);
}

and

class Product extends AppModel {

var $name = 'Product';

var $hasMany = array(
'Upload' => array(
'className' => 'Upload',
'foreignKey' => 'foreign_id',
'conditions' => array('Upload.class' => 'Product'),
'dependent' => true
)
);


}

John

On Jan 28, 2:11 pm, "Arak Tai'Roth"  wrote:
> That should help actually, as I am also using a seperate table to hold
> the images and then using associations to link them together. I am
> wondering though, how is your model coded to handle this, is it the
> same as it is for one image, or do you have to include a seperate
> entry of MeioUpload for each file input you have on your view form?
>
> On Jan 28, 8:04 am, Flipflops  wrote:
>
> > Hi
>
> > I'm using MeioUpload for a current project with multiple images. It is
> > a bit more complicated as I'm saving all the images into a single
> > table using a ploymorphic association (ie. Product hasMany Upload,
> > Profile hasOne Upload etc.) - but this should be helpful anyway
>
> > The upload fields generated in the view are organised like so:
>
> > 
> >         Filename
> >          > id="Upload1Filename" />
> > 
> > 
> >         Filename
> >          > id="Upload2Filename" />
> > 
>
> > etc.
>
> > For whatever reasons - probably the polymorphic association - I never
> > got this to work with saveAll, but anyway I have a bit of code to
> > upload / save the images uploaded from which ever model in
> > app_controller like this: (simplified example)
>
> > function upload_something($id = null) {
> >                 // id is the primary key of the parent model e.g Product
> >                 // e.g. Product hasMany Uploads
> >                 if (!$id) {
> >                         $this->flash(__('Invalid ' . $this->modelClass, 
> > true), array
> > ('action'=>'admin_index'));
> >                 }
>
> >                 if(!empty($this->data)){
>
> >                         if(isset($this->data['Upload'])){
>
> >                                 $upload_errors = array();
>
> >                                 foreach($this->data['Upload'] as $Upload => 
> > $value){
>
> >                                                         // only process the 
> > upload if it has actually been uploaded
> >                                                         
> > if(!empty($value['filename']['name'])){
>
> >                                                                 
> > $this->{$this->modelClass}->Upload->create();
>
> >                                                                 
> > $value['class'] = $this->modelClass;
> >                                                                 
> > $value['foreign_id'] = $id;
> >                                                                 
> > $this->{$this->modelClass}->Upload->save($value);
>
> >                                                                 
> > if(!empty($this->{$this->modelClass}->Upload->validationErrors)){
>
> >                                                                         
> > $upload_errors[$Upload]['filename'] =  
> > $this->{$this->modelClass}->Upload->validationErrors['filename'];
>
> >                                                                 }
> >                                                         }
>
> >                                 }
> >                         }
> >                 }
> >         }
>
> > Hope this helps.
>
> > John
>
> > On Jan 25, 10:57 pm, "Arak Tai'Roth"  wrote:
>
> > > I just recently star

Re: Multiple Uploads with MeioUpload

2009-01-28 Thread Arak Tai'Roth

That should help actually, as I am also using a seperate table to hold
the images and then using associations to link them together. I am
wondering though, how is your model coded to handle this, is it the
same as it is for one image, or do you have to include a seperate
entry of MeioUpload for each file input you have on your view form?

On Jan 28, 8:04 am, Flipflops  wrote:
> Hi
>
> I'm using MeioUpload for a current project with multiple images. It is
> a bit more complicated as I'm saving all the images into a single
> table using a ploymorphic association (ie. Product hasMany Upload,
> Profile hasOne Upload etc.) - but this should be helpful anyway
>
> The upload fields generated in the view are organised like so:
>
> 
>         Filename
>          id="Upload1Filename" />
> 
> 
>         Filename
>          id="Upload2Filename" />
> 
>
> etc.
>
> For whatever reasons - probably the polymorphic association - I never
> got this to work with saveAll, but anyway I have a bit of code to
> upload / save the images uploaded from which ever model in
> app_controller like this: (simplified example)
>
> function upload_something($id = null) {
>                 // id is the primary key of the parent model e.g Product
>                 // e.g. Product hasMany Uploads
>                 if (!$id) {
>                         $this->flash(__('Invalid ' . $this->modelClass, 
> true), array
> ('action'=>'admin_index'));
>                 }
>
>                 if(!empty($this->data)){
>
>                         if(isset($this->data['Upload'])){
>
>                                 $upload_errors = array();
>
>                                 foreach($this->data['Upload'] as $Upload => 
> $value){
>
>                                                         // only process the 
> upload if it has actually been uploaded
>                                                         
> if(!empty($value['filename']['name'])){
>
>                                                                 
> $this->{$this->modelClass}->Upload->create();
>
>                                                                 
> $value['class'] = $this->modelClass;
>                                                                 
> $value['foreign_id'] = $id;
>                                                                 
> $this->{$this->modelClass}->Upload->save($value);
>
>                                                                 
> if(!empty($this->{$this->modelClass}->Upload->validationErrors)){
>
>                                                                         
> $upload_errors[$Upload]['filename'] =  
> $this->{$this->modelClass}->Upload->validationErrors['filename'];
>
>                                                                 }
>                                                         }
>
>                                 }
>                         }
>                 }
>         }
>
> Hope this helps.
>
> John
>
> On Jan 25, 10:57 pm, "Arak Tai'Roth"  wrote:
>
> > I just recently started using the MeioUpload behaviour that I found
> > and I love it. However I am struggling to figure out how I can be
> > using it to do multiple file uploads.
>
> > I have a table and a seperate model and controller just for uploading
> > images, so one row in said table is equal to one image. Now I just
> > need to figure out how to use MeioUpload to upload multiple images in
> > one go (10 to be exact).
>
> > Any help on this would be greatly appreciated, thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Uploads with MeioUpload

2009-01-28 Thread Flipflops

Hi

I'm using MeioUpload for a current project with multiple images. It is
a bit more complicated as I'm saving all the images into a single
table using a ploymorphic association (ie. Product hasMany Upload,
Profile hasOne Upload etc.) - but this should be helpful anyway

The upload fields generated in the view are organised like so:


Filename



Filename



etc.

For whatever reasons - probably the polymorphic association - I never
got this to work with saveAll, but anyway I have a bit of code to
upload / save the images uploaded from which ever model in
app_controller like this: (simplified example)

function upload_something($id = null) {
// id is the primary key of the parent model e.g Product
// e.g. Product hasMany Uploads
if (!$id) {
$this->flash(__('Invalid ' . $this->modelClass, true), 
array
('action'=>'admin_index'));
}

if(!empty($this->data)){

if(isset($this->data['Upload'])){

$upload_errors = array();

foreach($this->data['Upload'] as $Upload => 
$value){

// only process the 
upload if it has actually been uploaded

if(!empty($value['filename']['name'])){



$this->{$this->modelClass}->Upload->create();

$value['class'] 
= $this->modelClass;

$value['foreign_id'] = $id;

$this->{$this->modelClass}->Upload->save($value);


if(!empty($this->{$this->modelClass}->Upload-
>validationErrors)){

$upload_errors[$Upload]['filename'] =  $this->{$this-
>modelClass}->Upload->validationErrors['filename'];
}
}

}
}
}
}



Hope this helps.

John

On Jan 25, 10:57 pm, "Arak Tai'Roth"  wrote:
> I just recently started using the MeioUpload behaviour that I found
> and I love it. However I am struggling to figure out how I can be
> using it to do multiple file uploads.
>
> I have a table and a seperate model and controller just for uploading
> images, so one row in said table is equal to one image. Now I just
> need to figure out how to use MeioUpload to upload multiple images in
> one go (10 to be exact).
>
> Any help on this would be greatly appreciated, thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Uploads with MeioUpload

2009-01-28 Thread WebbedIT

Not that I've used this behaviour or even tried uploading yet but
would have thought the solution lied in the naming of your fieldnames
to create an array and using the saveAll() method as follows:

For saving multiple records of single model $data needs to be a
numerically indexed array of records like this:

Array
(
  [0] => Array
(
  [fieldA] => fieldA 1
  [fieldB] => fieldB 1
  [fieldC] => fieldC 1
)
  [1] => Array
(
  [fieldA] => fieldA 2
  [fieldB] => fieldB 2
  [fieldC] => fieldC 2
)
)

The command for saving the above $data array would look like this:

$this->Model->saveAll($data['Article']);

Taken from the CookBook URL:
http://book.cakephp.org/view/75/Saving-Your-Data
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Uploads with MeioUpload

2009-01-28 Thread Chad Casselman
Was a solution for this ever found?  I need the same thing.  I really like
using Meio but must get multiple files working.  I am still unclear on all
the magic in cakephp or I would try to modify the script myself, but no
where to even start looking - right now.

Chad



On Mon, Jan 26, 2009 at 2:20 PM, Arak Tai'Roth wrote:

>
> I already have the code and everything working to upload one image,
> that is not the issue at hand.
>
> I want to be able to upload multiple images with MeioUpload. I wish to
> use this method because it can automatically create thumbnails for me,
> and there is very minimal amount of code that I need to use to make it
> work.
>
> I am open to other methods so long as they can upload thumbnails as
> well, and aren't that code intensive.
>
> On Jan 26, 11:40 am, gerhardsletten  wrote:
> > Are using MeioUpload on my last project to as Article has many
> > Uploads. When editing an article you can upload one and one image.
> > Your will find source here:
> http://code.google.com/p/gerhardsletten/source/browse/trunk/cakephp/s...
> >
> > If you need your app to upload all in one bunsh, I guess you can use
> > the $model->saveAll() and add several uploadsfields in an array.
> > Search in this group for "save multiple" or "saveall"
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Uploads with MeioUpload

2009-01-26 Thread Arak Tai'Roth

I already have the code and everything working to upload one image,
that is not the issue at hand.

I want to be able to upload multiple images with MeioUpload. I wish to
use this method because it can automatically create thumbnails for me,
and there is very minimal amount of code that I need to use to make it
work.

I am open to other methods so long as they can upload thumbnails as
well, and aren't that code intensive.

On Jan 26, 11:40 am, gerhardsletten  wrote:
> Are using MeioUpload on my last project to as Article has many
> Uploads. When editing an article you can upload one and one image.
> Your will find source 
> here:http://code.google.com/p/gerhardsletten/source/browse/trunk/cakephp/s...
>
> If you need your app to upload all in one bunsh, I guess you can use
> the $model->saveAll() and add several uploadsfields in an array.
> Search in this group for "save multiple" or "saveall"
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Re: Multiple Uploads with MeioUpload

2009-01-26 Thread gerhardsletten

Are using MeioUpload on my last project to as Article has many
Uploads. When editing an article you can upload one and one image.
Your will find source here:
http://code.google.com/p/gerhardsletten/source/browse/trunk/cakephp/surdeig/models/upload.php?r=6

If you need your app to upload all in one bunsh, I guess you can use
the $model->saveAll() and add several uploadsfields in an array.
Search in this group for "save multiple" or "saveall"



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---



Multiple Uploads with MeioUpload

2009-01-25 Thread Arak Tai'Roth

I just recently started using the MeioUpload behaviour that I found
and I love it. However I am struggling to figure out how I can be
using it to do multiple file uploads.

I have a table and a seperate model and controller just for uploading
images, so one row in said table is equal to one image. Now I just
need to figure out how to use MeioUpload to upload multiple images in
one go (10 to be exact).

Any help on this would be greatly appreciated, thanks in advance.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~--~~~~--~~--~--~---