首页 > 解决方案 > 防止在 Uikit 3.7.0 中自动上传文件

问题描述

在 UIKit 3.7.0 中,我有一个上传框,用户可以(自然地)将文件放入其中。但是,我希望使用提交按钮而不是自动上传来提交文件。

在stackoverflow的其他地方,建议通过以下参数停止上传方法UIkit.uploaddrop

method: () => {return false; }

但是,这似乎不再起作用,因为这会引发以下错误: Uncaught DOMException: Failed to execute 'open' on 'XMLHttpRequest': '() => {return false; }' is not a valid HTTP method.

所以问题是:是否有新的方法来防止文件上传?

作为参考,这里是使用的完整 JS 代码:

$(function() 
{ 
    altair_form_file_upload.init()}), 
    altair_form_file_upload = {
        init: function()
        { 
            var o = $('#uploadarea'),
            e = o.find('.uk-progress-bar'),
            t = {method: () => {return false; },
            allow: '*.(xls|xlsx)',
            loadstart: function() {
                e.css('width', '0%').text('0%'), 
                o.removeClass('uk-hidden')
            },
            progress: function(t) {
                t = Math.ceil(t), 
                e.css('width', t + '%').text(t + '%')},
                single: true,
                allcomplete: function(t, i) {e.css('width', '100%').text('100%'), 
                setTimeout(function() {o.addClass('uk-hidden')}, 250)
            }
        };
        UIkit.uploadSelect($('#uploadbutton'), t), 
        UIkit.uploadDrop($('#uploadbox'), t)
    }
};

标签: javascriptgetuikit

解决方案


推荐阅读