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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

ModelAdmin Image Upload Folder


3 Posts   1604 Views


16 April 2010 at 8:14pm (Last edited: 16 April 2010 8:15pm), Community Member, 6 Posts


there has been a problem uploading images using ImageField which seemed to be resolved in 2.4 ( and").

I still struggle with changing the upload folder when I use the scaffolded upload of a subclass of ModelAdmin. Since I do not implement an ImageField, the workaround is not working and my 'upload'-folder is overflowing.

How can I change the default upload location in ModelAdmin in combination with $has_one Image?




18 April 2010 at 11:51pm (Last edited: 18 April 2010 11:52pm), Community Member, 6 Posts

Well, I found a q&d-workaround: open the file sapphire/forms/filefield.php and edit line 66 from

protected $folderName = 'Uploads';


protected $folderName = 'Uploads/myImageFolder';

That helps untill the next silverstripe update. But at least it helps.


24 June 2012 at 6:11am Community Member, 4 Posts

I was able to get it working by setting the image upload folder using the getCMSFields() method. Here's what I've got.

//the class that defines the top level tab
class MyNewSection extends ModelAdmin {

public static $managed_models = array( //since 2.3.2

static $url_segment = 'mytaburl'; // will be linked as /admin/products
static $menu_title = 'My Model Items';


class MyModelName extends DataObject {
static $db = array(
'Title' => 'Text'

static $has_one = array(
"Image" => "Image"

static $searchable_fields = array(

function getCMSFields() {
$fields = parent::getCMSFields();
$lField = new ImageField("Image", "My Model Photo");

$fields->addFieldToTab("Root.Main", $lField);
return $fields;