5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2363 Views |
-
Upload::setAllowedExtensions() is deprecated

4 April 2010 at 2:52am Last edited: 4 April 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
-
Re: Upload::setAllowedExtensions() is deprecated

6 April 2010 at 4:05am Last edited: 6 April 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...
-
Re: Upload::setAllowedExtensions() is deprecated

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'));
$image->setValidator($image_validator);
$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.
-
Re: Upload::setAllowedExtensions() is deprecated

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 ssbits.com on the following URL:
http://www.ssbits.com/tutorials/2009/embed-flash-content-using-swfobject/
<?php
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)');
$fileUpload->setAllowedExtensions(array('swf'));$fields->addFieldsToTab('Root.Content.Flash', array(
$fileUpload,
new HtmlEditorField('AlternateContent', 'Flash replacement text', 20)
));return $fields;
}
}
class FlashPage_Controller extends Page_Controller
{
}
| 2363 Views | ||
|
Page:
1
|
Go to Top |



