Hey, Tarique maybe you can help with this as I've just viewed your
cheesecake site.

I've been working on a photo gallery set and want to be able to upload
multiple files at one. A user could browse to images and select more
than one, then upload. The best example I can provide for what I'd
like to do is <a href="http://slideshowpro.net/products/
slideshowpro_director/slideshowpro_director">Slideshow Pro Director</
a> (they use cake too!).

So far the only it looks really possible is using Flash on the client
side to be able to select multiple files. This is what SSP does. I've
created a nice little interface in Flex thanks to a couple of nice
tutorials available. It works well (except on Macs) for the most part.
What I don't like about it is it's not Cake friendly. I ended up
having to create an "upload" script in straight php, load it into
webroot. The flash element calls that script to upload the files. It's
nice because it's all PHP and I don't have to worry about any CGI
support. The Flash element treats each file as a separate upload and
just loops through calling the script each time. Probably not the most
efficient, but I don't run into session time outs either.

I have been unsuccessful trying to get the upload process into an
actual controller. I can pass all kinds of variables through Flash and
save them to the DB just fine, but the image files doesn't make it. I
would assume that it's something in my flash files that not sending
the image correct. I've read a little about a cake upload component,
but haven't dove into it yet. I'm more than happy to send you the
Flash file and scripts if that would help.

Russ

On Nov 8, 4:43 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
> I think your solution is very good, but it does not suit my needs as
> the system I am building is rather complex.
>
> Instead I am going to use the following solution to store all my
> images:
>
> Images table:
> id
> foreign_id   //user_id
> associated_model //User...    -- Image->belongsTo = User/Shop/Album/
> Profile/More....
> upload_comment // belongsTo $this->AssociatedModel->name
> filename
> full_path //stored in files.image.associated_model.filename
> has_thumb
> thumbs = serialized array  //small / large / medium / xlarge
> ext
> created
> updated
>
> -----------------
>
> Then albums will have the following association:
>
> --Profile
> var $hasMany = array(
>         'Image' => array(
>                 'className' => 'Image',
>                 'foreignKey' => 'foreign_id', //profile_id
>                 'conditions' => array( 'Image.associated_model' => 'Profile'),
>         )
> );
>
> --Shop
> var $hasMany = array(
>         'Image' => array(
>                 'className' => 'Image',
>                 'foreignKey' => 'foreign_id', //shop_id
>                 'conditions' => array( 'Image.associated_model' => 'Shop'),
>         )
> );
>
> --Product
> var $hasAndBelongsToMany = array(
>         'Image' => array(
>                         'className'                             => 'Image',
>                         'joinTable'                     => 
> 'shop_images_products',
>                         'foreignKey'                    => 'product_id',
>                         'associationForeignKey'         => 'image_foreign_id',
>                         'fields'                                        => '',
>                         'conditions' => array( 'Image.associated_model' => 
> 'Shop'),
>                         'unique'                        => true,
>         )
> );
>
> Thats the solution I will be using, hope it works.
>
> I might even write a tutorial about this later....
>
> Thank you all once again for helping out.
>
> On Nov 8, 8:21 am, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > Well, not really, you just need one images table for that.
>
> > Then in your models you just have an image_id, and set your
> > associations up like this:
>
> > class Shop extends AppModel {
>
> >         var $belongsTo = array(
> >                 'Image' => array('className' => 'Image', 'foreignKey' => 
> > 'image_id')
> >         );
>
> > }
>
> > class Album extends AppModel {
>
> >         var $belongsTo = array(
> >                 'Image' => array('className' => 'Image', 'foreignKey' => 
> > 'image_id')
> >         );
>
> > }
>
> > If you need more than one image associated, then just use a habtm
> > association and create a join table!
>
> > I've been using this method for over a year and a half and I've never
> > thought about doing it any other way.
>
> > Cheers,
> > Adam
>
> > On Nov 8, 9:29 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > That does help Adam.  Thats exactly the way I will do it now.
>
> > > But I think I will end up with many tables which is what really puts
> > > me off.  But thats not a problem.
>
> > > Should have ShopImage, AlbumImage ProfileImage and so on...
>
> > > Many thanks to all for helping out.
>
> > > Cheers
>
> > > On Nov 7, 10:42 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
>
> > > > The way I do this:
>
> > > > Tables:
> > > > - images
> > > > - videos
> > > > - documents
>
> > > > Each of the tables has the standard fields like mime_type, filesize,
> > > > path, etc. And each custom type has any extra fields that may be
> > > > necessary (width, height, duration, bitrate, etc).
>
> > > > Behaviors:
> > > > - FileBehavior
> > > > - ImageBehavior extends FileBehavior
> > > > - VideoBehavior extends FileBehavior
>
> > > > The reason I split into multiple tables is for associations. Often I
> > > > want to control what media types are associated with my models. Eg. I
> > > > might want a model to have many images but just one video. Plus, this
> > > > prevents you from having to constantly check the media type if you're
> > > > iterating through one array with multiple media types.
>
> > > > Hope that helps.
>
> > > > Cheers,
> > > > Adam
>
> > > > On Nov 8, 3:06 am, Marcus Silva <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi folks,
>
> > > > > I am trying to create system which will let users upload media to the
> > > > > server,  the question that I ask is weather using a single table to
> > > > > store the uploaded files is better than using separate tables to store
> > > > > each file type in terms of coding.
>
> > > > > Seems to me that if I use the multiple table I will be creating
> > > > > exactly the same data, but in a different table.
>
> > > > > Example:  audios,videos,images etc....
>
> > > > > My table structure:
>
> > > > > CREATE TABLE `uploaded_files` (
> > > > >   `id` int(11) unsigned NOT NULL auto_increment,
> > > > >   `foreign_id` int(10) unsigned NOT NULL,
> > > > >   `model` varchar(255) NOT NULL COMMENT 'Associated model name',
> > > > >   `media` varchar(55) NOT NULL,
> > > > >   `filename` varchar(255) default NULL,
> > > > >   `ext` varchar(10) default NULL,
> > > > >   `mime` varchar(55) default NULL,
> > > > >   `filesize` int(11) NOT NULL,
> > > > >   `webpath` varchar(255) NOT NULL COMMENT 'Web path to show file',
> > > > >   `full_path` text NOT NULL COMMENT 'Full path to file_src',
> > > > >   `hasThumb` tinyint(1) unsigned NOT NULL,
> > > > >   `thumbs` text,
> > > > >   `width` int(11) default NULL,
> > > > >   `height` int(11) default NULL,
> > > > >   `description` varchar(155) default NULL,
> > > > >   `created` datetime default NULL,
> > > > >   `updated` datetime default NULL,
> > > > >   PRIMARY KEY  (`id`)
> > > > > ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
>
> > > > > Basically, I am looking for an easy solution that will reduce the
> > > > > amount of code I write....
>
> > > image> > Hope some of you guys can help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to