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, Ed, biapar, Willr, Ingo, swaiba

ModelAdmin Image Upload Folder

Go to End

3 Posts   2154 Views


Community Member, 6 Posts

16 April 2010 at 8:14pm

Edited: 16/04/2010 8:15pm


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?




Community Member, 6 Posts

18 April 2010 at 11:51pm

Edited: 18/04/2010 11:52pm

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.


Community Member, 4 Posts

24 June 2012 at 6:11am

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;