Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Upload::setAllowedExtensions() is deprecated

Go to End

4 Posts   4161 Views


Community Member, 203 Posts

4 April 2010 at 2:52am

Edited: 04/04/2010 2:54am

When trying to control the file types that can be uploaded in a File -i get the following message:

ERROR [User Notice]: Upload::setAllowedExtensions() is deprecated. Please use Upload_Validator::setAllowedExtensions() instead

Anybody has the scoop on this one?

I have been looking in the forums docs and in my sites code, but it is not clear to me how to use Upload_Validator::setAllowedExtensions()

EDIT: am using 2.4 beta2


Community Member, 141 Posts

6 April 2010 at 4:05am

Edited: 06/04/2010 4:09am

I am using 2.4.0rc1 and i'm currently staring at the same error message.
It seems to me that there is no Upload_Validator class in sapphire... oO /confused...

Edit: Arrgh, found Upload_Validator; it's in Upload.php as well...


Community Member, 98 Posts

10 April 2010 at 3:58am

Contrary to the notice, it's actually Upload_Validator->setAllowedExtensions(). For those interested, here's how I got it working:

		$image = new FileIFrameField('CarouselImage', 'Carousel Image (JPEG files only)');
		$image->allowedExtensions = array('jpg', 'jpeg');
		$image_validator = new Upload_Validator();
		$image_validator->setAllowedExtensions(array('jpg', 'jpeg'));
		$fields->replaceField('CarouselImage', $image);

This replaced an existing image field in ModelAdmin. It only performs validation on the server side. Am I right in thinking it should be possible to limit file types in the file upload dialog box too? Cos I haven't been able to figure it out... SWFUpload can do it, but I'm getting a Class 'Image_Uploader' not found error when trying to use it in ModelAdmin.


Community Member, 24 Posts

3 May 2012 at 4:05am

ERROR [User Notice]: Upload::setAllowedExtensions() is deprecated. Please use Upload_Validator::setAllowedExtensions() instead

Getting same sort of error while using the following code from on the following URL:

class FlashPage extends Page
public static $db = array(
'AlternateContent' => 'HTMLText'

public static $has_one = array(
'FlashFile' => 'File'

public function getCMSFields(){
$fields = parent::getCMSFields();

// create a file upload field that only allows swf to be uploaded
$fileUpload = new FileIFrameField('FlashFile', 'Flash file (swf)');

$fields->addFieldsToTab('Root.Content.Flash', array(
new HtmlEditorField('AlternateContent', 'Flash replacement text', 20)

return $fields;
class FlashPage_Controller extends Page_Controller