Hello everyone,
Im using Kirby Authentication.
I want to “users” can upload photos to page.yaml -> “Structure”.
How can i do this?
Good works!
What do you mean? Do you want users to upload images from the frontend and then add the image filename to a structure field?
Exactly that i want
how can i do this
Here is some example code using the Upload class: Allow guests to create pages from Panel or frontend
After the file is uploaded, you can use $page->update()
to update the page. Here is a little function for updating a structure field:
function addToStructure($page, $field, $data = array()){
$fieldData = page($page)->$field()->yaml();
$fieldData[] = $data;
$fieldData = yaml::encode($fieldData);
try {
page($page)->update(array($field => $fieldData));
return true;
} catch(Exception $e) {
return $e->getMessage();
}
}
3 Likes