In order to get around this issue of having multiple models using the
FileUpload.FileUpload behavior I did the following:
created two additional behavior files:
private_file_upload.php and public_file_upload.php in /app/plugins/
file_upload/models/behaviors
containing the following code respectively:
<?php
App::Import('Behavior','FileUpload.file_upload');
class PrivateFileUploadBehavior extends FileUploadBehavior {
}
?>
<?php
App::Import('Behavior','FileUpload.file_upload');
class PublicFileUploadBehavior extends FileUploadBehavior {
}
?>
then in the model configurations I changed
var $actsAs = array(
'FileUpload.FileUpload'
to
var $actsAs = array(
'FileUpload.PrivateFileUpload'
and
var $actsAs = array(
'FileUpload.PublicFileUpload'
This has allowed me to use two separate configurations for each upload
type, you can probably use this same method, just create separate
behavior files to extend the base FileUpload for each different
configuration you want to have.
On Sep 22, 12:05 am, Wanna be baker <[email protected]> wrote:
> I have a Shirt which has many different images
> - shirt_image
> - thumb_on_image
> - thumb_off_image
> - price_banner_image
>
> The files get stored in separate places (or are supposed to be). What
> I've found (using a model like what is show here:http://pastebin.com/gbnLpxN0)
> is that the value ofuploadDirgets overwritten. Net, the last
> declaration of it affects all of the other executions. Couple this
> with the fact that I can't figure out how to get DS into theuploadDir
> declaration, has caused me some good sized headaches.
>
> At the moment, with the constructor call commented out and the .{DS}.
> in the actsAs, this blows up... but it does work if I use the
> constructor method; it'sjustthat the files get stored in the wrong
> spots...
>
> The variable issue lead me to try using the constructor to affect that
> option. However, even that has the same issues with the value being
> overridden.
>
> As a result, I have two questions... One specific and one high level.
>
> Specific: how can I get this declaration ofuploadDirset correctly so
> that different models can have different uploadDirs?
>
> High-level: How does this get instantiated (this plugin)? Does it
> instantiate one instance of the behavior at run time or does it create
> one for each model? If it's the latter, it's not working as I would
> expect. Also, where's a good tutorial that would help me understand
> the OO nature and instantiation order in CakePHP?
>
> Thanks!
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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