How to use

Copy-paste the following <script> near the end of your pages under JS Implementing Plugins to enable it.

              
                <script src="../node_modules/hs-file-attach/dist/hs-file-attach.min.js"></script>
              
            

Copy-paste the init function under JS Plugins Init., before the closing </body> tag, to enable it.

              
                <script>
                  $(document).on('ready', function () {
                    // INITIALIZATION OF CUSTOM FILE
                    // =======================================================
                    $('.js-file-attach').each(function () {
                      var customFile = new HSFileAttach($(this)).init();
                    });
                  });
                </script>
              
            

Custom file input

Custom file btn

Avatar uploader

Custom file boxed

Methods

Parameters Description Default value

allowTypes

Supported file types. If empty all supported. []

maxFileSize

Max size for uploading file. 1024

mode

Supported two mods (image/simple). image - show image after uploading. simple - show file name after uploading. simple

targetAttr

Element selector with src for image mode. null

textTarget

Element selector for simple mode. null

resetTarget

Element selector to reset form. null

errorMessage

Error message text if the file size is larger than the allowed. 'File is too big!'

typeErrorMessage

Error message text if file type is not supported. 'Unsupported file type'