I'm trying to create a form, on the front end, where users can upload a logo.
I am using a SimpleImageField
$fields = new FieldSet(
.
.
.
new SimpleImageField (
$name = "LogoImageID",
$title = "Upload a logo (2Mb maximum filesize)"
)
);
.
.
.
$form = new Form($this, 'ShowProfileForm', $fields, $actions, );
return $form;
}
function btnSaveInfo($data, $form) {
$file = new File();
$file->loadUploaded($_FILES['LogoImageID']);
And that WORKS, except that the Image is saved with a ClassName of "File" rather than "Image". So it doesn't display on the template or do anything useful.
I can't find any documentation on how to set the ClassName.
When I try updating the ClassName with a DataObject::get_by_id, I get a message about backlinktracking not being supported. And anyway, it's a total kludge of a solution.
At the moment, I can get it to work by simply updating the record with a DB:query (even more of a kludge), but there's got to be a better solution.
I can't be the only guy that's noticed this problem, so I am sure I'm doing something wrong.
Any suggestions?