I am using a Plugin for CakePHP - AjaxMultiUpload (a fine plugin :-) - but I have a question about how to change/access a variable that is defined in the Controller that is part of the Plugin.
I have used this plugin before and like it. But I am trying to restrict what file types are allowed to be uploaded based on which controller I have attached the Component to.
In the Plugin there is a Controller - UploadsController.php. In this class, there is a public variable:
// list of valid extensions, ex. array("jpeg", "xml", "bmp")
public $allowedExtensions = array();
If I change this to:
public $allowedExtensions = array('mp3');
when I try to upload a .jpg file, an error message is issued (as one would hope :-).
In my controller (Tracks) I have attached the AjaxMultiUpload Plugin. It works. In the beforeFilter() method in my Tracks controller, I have placed the following line:
$this->Upload->allowedExtensions = array('mp3');
This had no effect. (Incidentally, there are no warnings thrown telling me I have tried to access something that doesn't exist).
I don't want to change the contents of the array allowedExtensions by hard-coding it in the Plugin's controller. This is bad for 2 reasons: 1) updatability of the Plugin and 2) I want to change the restrictions (audio file types versus image file types, for example) based on which of my controllers (Tracks, Images, etc.) the Plugin is attached to.
What I don't understand is the relationship between the Component (attached to the Tracks controller) and the UploadsController that is part of the Plugin. What instantiates the UploadsController that is part of the Plugin? Does this happen automagically?
Can anyone help?
Thanks, Ken