How to make file uploader in magento 2

Magento2: UI Component File Uploader html and js

<div class="upload-wrapper" data-bind="scope: 'uploader'">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>

<script type="text/x-magento-init">
{
".upload-wrapper": {
   "Magento_Ui/js/core/app": {
       "components": {
           "uploader": {
               "component": "Magento_Ui/js/form/element/file-uploader",
               "template": "ui/form/element/uploader/uploader",
               "allowedExtensions": ["png", "jpg", "jpeg", "gif"],
               "uploaderConfig": {
                    "url": "<?php echo $block->getUrl('customer/account/family'); ?>"
               }
            }
        }
   }
 }
}
</script>

Leave a Reply

Your email address will not be published. Required fields are marked *