Upload image with custom form

I created a custom form in a new plugin, i wanna do upload image together. How i do it? I tried copy the avatar upload script but doesn't work.


  • How do you know it's not working? Do you get some kind of an error? Do any files appear to the data directory? Does the global $_FILES variable get populated in the save action?

  • I don't get a any error, nothing. No, the files not in directory of uploads.  $_Files is empty.

    But i missed the 'enctype' => 'multipart/form-data' in elgg_view_form, so i solved this problem.


        $resized = get_resized_image_from_uploaded_file('image_upload', 120, 120, false, true);

            $filehandler = new ElggFile();
            $filehandler->owner_guid = $guid_classified;
            $filehandler->setFilename("classified/" . $guid_classified . "-classified.jpg");

  • @Marcelo de Andrade, what is the main purpose for your custom 120px by 120px image form? Is it to allow your users to place ads or advertise on your site?

  • Yes, @Tom. I created a space for ads in my elgg site and the users can upload a image