10929 Posts in 2613 Topics by 1809 members
|Go to End|
23 March 2010 at 10:57am Last edited: 23 March 2010 10:58am
Is there a way to add this to file? I've tried using a DataObject decorator, and tried subclassing File (ie.
class MyFile extends file
static $allowed_extensions = array('someNewExtension');
but neither of those seem to work. The only thing that seems to work is manually adding it to the core File class.
23 March 2010 at 1:15pm
I'm pretty sure $allowed_extensions has to go on the DataObject that contains the File.
23 March 2010 at 3:53pm
So it would look something more like
class SomeDataObject extends DataObject
static $has_many = array ('Files' => 'MyFile');
static $allowed_extensions = array('pdf');
class MyFile extends File
Does that seem more right?
23 March 2010 at 4:34pm
Yeah, that looks good.
23 March 2010 at 4:37pm
Haha, nope =) Throws an error with SWF Upload
23 March 2010 at 4:39pm
Only way I can get it to work is by adding 'psd' to the core File $allowed_extensions definition =(
23 March 2010 at 4:44pm
What are you trying to do? What was the error?
23 March 2010 at 4:54pm
Well, I finally got SWFUpload to upload Files that are attached to a DataObject, except I started running into an error when trying to upload PSD files, which will be the primary type I need to upload. SWFUpload is giving the generic 500 internal server error, so I started Googling around, and found that a common cause was max file size. I checked that, it was right, so I dug down and figured out that File does not accept PSD file types, so it was throwing an error, even though I set SWFUpload to accept those (which I'm now assuming only controls the select window on the client side).
So I found the File base class, and $allowed_extensions, added 'psd' to the end of the array, and now it works. I don't like that, because it's not very modular, and I'm having to change the core to make my module work, which is kind of yuck, so I've been trying to find a way to extend from the base class and add more $allowed_extensions, but nothing seems to work.
|Go to Top|