This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

xyz.qtc63355
xyz.qtc63355

I followed up a tutorial for uploading and previewing a single image, and it's pretty cool. But it's kinda unfinished. How can I build /implement a widget similar to the file uploader in the backend forms?

xyz.qtc63355
xyz.qtc63355

Ok, this one was really easy.

  1. Install https://octobercms.com/plugin/responsiv-uploader
  2. There are two methods, 1. Attaching the uploader (from page) 2.Attaching the uploader (from component)
  3. Follow the instructions, read the docs.

    public function init()
    {
        $component = $this->addComponent(
            'Responsiv\Uploader\Components\ImageUploader',
            'imageUploader',
            ['deferredBinding' => true]
        );
    
        $component->bindModel('photos', new Ad);
    }

    in default.htm

    {% component 'imageUploader' %}

Last updated

xyz.qtc63355
xyz.qtc63355

I have a problem with this plugin. The images are being saved in my upload folder, which is fine if I save the new model, and if I don't save the new Model, the images are still there.

How to prevent this?

daftspunky
daftspunky

The images should get cleaned up by the deferred binding process. You can trigger this manually too if you like:

// Delete records that are 5 days old
October\Rain\Database\Models\DeferredBinding::cleanUp(5);
xyz.qtc63355
xyz.qtc63355

I read that, so it is done automatically right? Perfect!

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.