javascript - 防止在 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)
}
};
解决方案
推荐阅读
- python - GAN 从一开始就在训练中卡住了
- r - 从 R 获取给定形状文件的随机 lon 和 lat 坐标数据集
- azure - 要在 SAP 连接器中读取的字段传递的参数:读取 SAP 表(预览版)
- python - 找到相同字符串的重复字符串
- javascript - 搜索数组以查找峰值的最佳方法,无需拆分或创建新数组,javascript
- javascript - Javascript如何显示当前图像索引和图像总数
- node.js - 无服务器离线 - API REST 节点打字稿
- javascript - 在 iOS 上的社交应用中转义应用内 Safari
- elasticsearch - 如何使用 Nest Fluent DSL 生成索引聚合?
- python-3.9 - ValueError:无法将字符串转换为浮点数:'Setup..\r\n'