Upload images

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.

  • 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:




    $filehandler = new ElggFile();

    $filehandler->owner_guid = $entity->owner_guid;

    $filehandler->setFilename($prefix . $image);





    $gg = $filehandler->getGUID();


    $entity->addRelationship($gg, 'photo');



    And this for view the image:


    $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.