Hi everybody. Sorry for my bad english.
I'm a newbie in elgg. I've made a simple form with some text fields. I want to add an upload image field but i'm a bit lost with it. I tried to add a input/file field but i can't know where is the file and how show the image etc. Somebody con help me?
Thanks to all.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Evan Winslow@ewinslow
Evan Winslow - 0 likes
- jddes@josediegorobles
jddes - 0 likes
- jddes@josediegorobles
jddes - 0 likes
You must log in to post replies.Have you looked at how the file plugin does this?
Thank you. I'm going to try.
Hi.
I tried this in my input form:
<dd><?php echo elgg_view('input/file', array('internalname' => 'image', 'value' => $image)); ?></dd>
this in my /action/edit.php:
if($image)
{
$filehandler = new ElggFile();
$filehandler->owner_guid = $entity->owner_guid;
$filehandler->setFilename($prefix . $image);
$filehandler->open("write");
$filehandler->write(get_uploaded_file('upload'));
$filehandler->close();
$filehandler->save();
$gg = $filehandler->getGUID();
}
$entity->addRelationship($gg, 'photo');
$entity->image_guid=$filehandler->guid;
And this for view the image:
<?php
$imagen = get_entity($vars['entity']->image_guid);
echo "<img src='{$imagen->getFilename}' border='0' width='300' height='100'>";
?>
The image appears tu save correctly and i can obtain the guid of the image. But when i get the entity for this guid the methods for ElggFile aren`t going. Anybody can see what's the problem.
Sorry, but i'm really a newbie on elgg and php. Thanks.