This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
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?
Ok, this one was really easy.
- Install https://octobercms.com/plugin/responsiv-uploader
- There are two methods, 1. Attaching the uploader (from page) 2.Attaching the uploader (from component)
-
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
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?
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);
1-5 of 5