I have been trying to save an Elgg entity icon in Elgg 3.x but to no success. myObject saves into the database, but the file doesn't get uploaded.
What is it that I am doing wrong?
Thank you all in advance.
save.php form
<?php
echo elgg_view('input/file', [
'name' => 'upload[]',
'multiple' => true,
'label' => 'picTuREs',
]);
?>
save.php action file
foreach (elgg_get_uploaded_files('upload') as $upload)
{
$myObject = new ElggObject();
$myObject->subtype = "my_object";
$myObject->access_id = ACCESS_PUBLIC;
$myObject->saveIconFromUploadedFile($upload);
$myObject->save();
}
Update your action on this:
If you use a custom subtype then you should extend
\ElggFilevia this object something like this: