Javascript 如何在google drive文件上载上运行预加载程序
我有一个html使用应用程序脚本。此html接受用户的输入和文件上载Javascript 如何在google drive文件上载上运行预加载程序,javascript,html,google-apps-script,Javascript,Html,Google Apps Script,我有一个html使用应用程序脚本。此html接受用户的输入和文件上载 <div class="inside_form file_upload"> <label>Upload Resume: </label> <input id="file" type="file" onchange="saveFile(this)" class="custom_inputs"
<div class="inside_form file_upload">
<label>Upload Resume: </label>
<input id="file" type="file" onchange="saveFile(this)" class="custom_inputs">
</div>
<div class="input-field col s7">
<button id="btn" class="btn blue-grey darken-3 waves-effect waves-light right">Submit<i class="mdi-content-send right"></i></button>
</div>
服务器端代码
function saveFile(e) {
var blob = Utilities.newBlob(e.bytes, e.mimeType, e.filename);
DriveApp.getFolderById('0AIigAJ4047IdUk9PVA').createFile(blob);
var file = DriveApp.getFilesByName(e.filename).next().getId();
Logger.log(file);
}
现在的问题是,有时上传文件需要时间,用户可以在上传文件之前启动提交按钮
我想在文件开始加载后阻止显示,并在加载完成后停止显示。默认情况下,按钮:
<button id="btn" class="btn blue-grey darken-3 waves-effect waves-light right" disabled>Submit<i class="mdi-content-send right"></i></button>
可以使用
display:none
和display:block
切换元素的可见性。因此,您应该在启动时隐藏它,并在google.script.run.withSuccessHandler
激发时使其可见。我尝试使用一些代码,但失败了,我到底在哪里可以进行更改。如果你能再简短一点,或者把它写在回答中,那将是非常有帮助的。因为你给我们的代码不完整:google+referstuff没有定义,我无法对它进行完整的测试。好的,如果我发布的代码太长了,我会编辑我的问题。完成编辑我的问题。有时,如果我有太长的代码,我会在这里发布主要部分,并为那些想要获得更多信息的人链接到一个带有较长代码的jsfiddle.net示例(这也是尽可能短的)。我们需要google
的定义。你只给了我们一些简单的警报可以模仿的东西。
<button id="btn" class="btn blue-grey darken-3 waves-effect waves-light right" disabled>Submit<i class="mdi-content-send right"></i></button>
google.script.run.withSuccessHandler(e => {
console.log(e);
document.getElementById("btn").disabled = false;
}).saveFile(obj);