如何修改我此脚本允许多个文件上传或者甚至超过5 MB更大的文件?
当前脚本:
<!-- Written by Amit Agarwal [email protected] -->
<form class="main" id="form" novalidate="novalidate" style="max-width: 480px;margin: 40px auto;">
<div id="forminner">
<div class="row">
<div class="col s12">
<h5 class="center-align teal-text">Submit My Article</h5>
<p class="disclaimer">This <a href="http://www.labnol.org/internet/file-upload-google-forms/29170/">File Upload Form</a> (<a href="https://youtu.be/C_YBBupebvE">tutorial</a>) Powered by <a href="https://ctrlq.org/code/19747-google-forms-upload-files" target="_blank">Google Scripts</a></p>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="name" type="text" name="Name" class="validate" required="" aria-required="true">
<label for="name">Article Headline</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="email" type="email" name="Email" class="validate" required="" aria-required="true">
<label for="email"><a href="https://www.google.com.tw/search?newwindow=1&rlz=1C1NHXL_zh-TWTW740TW740&q=byline+%E4%B8%AD%E6%96%87&oq=byline+%E4%B8%AD%E6%96%87&gs_l=psy-ab.3..0j0i8i10i30k1.13478.26153.0.27447.10.9.1.0.0.0.139.542.8j1.9.0....0...1.1j4.64.psy-ab..0.6.346...0i67k1j0i22i30k1j33i160k1.7bxnoHhXH84">Byline</a> (English, Chinese and/or <a href="https://www.google.com.tw/search?newwindow=1&rlz=1C1NHXL_zh-TWTW740TW740&q=pseudonym+%E4%B8%AD%E6%96%87&oq=pseudonym+%E4%B8%AD%E6%96%87&gs_l=psy-ab.3..0.2596.6799.0.7633.14.10.4.0.0.0.95.562.10.10.0....0...1.1j4.64.psy-ab..0.10.388...0i22i30k1j33i160k1.YTjT9Ex_16I">Pseudonym</a>)</label>
</div>
</div>
<div class="row">
<div class="file-field input-field col s12">
<div class="btn">
<span>File</span>
<input id="files" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Select a File to Upload">
</div>
</div>
</div>
<div class="row">
<div class="file-field input-field col s12">
<div class="btn">
<span>File</span>
<input id="files" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Select a File to Upload">
</div>
</div>
</div>
<div class="row">
<div class="file-field input-field col s12">
<div class="btn">
<span>File</span>
<input id="files" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Select a File to Upload">
</div>
</div>
</div>
<div class="row">
<div class="file-field input-field col s12">
<div class="btn">
<span>File</span>
<input id="files" type="file">
</div>
<div class="file-path-wrapper">
<input class="file-path validate" type="text" placeholder="Select a File to Upload">
</div>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<button class="waves-effect waves-light btn submit-btn" type="submit" onclick="submitForm(); return false;">Submit</button>
</div>
</div>
<div class="row">
<div class="input-field col s12" id = "progress">
</div>
</div>
</div>
<div id="success" style="display:none">
<h5 class="left-align teal-text">File Uploaded</h5>
<p>Your file has been successfully uploaded.</p>
<p>The <a href="http://www.labnol.org/internet/file-upload-google-forms/29170/">pro version</a> (see <a href="">demo form</a>) includes a visual drag-n-drop form builder, CAPTCHAs, the form responses are saved in a Google Spreadsheet and respondents can upload multiple files of any size.</p>
<p class="center-align"><a class="btn btn-large" href="https://gum.co/GA14?wanted=true" target="_blank">Upgrade to Pro</a></p>
</div>
</form>
<div class="fixed-action-btn horizontal" style="bottom: 45px; right: 24px;">
<a class="btn-floating btn-large red">
<i class="large material-icons">menu</i>
</a>
<ul>
<li><a class="btn-floating red" href="https://gum.co/GA14" target="_blank" title="Buy License - File Upload Form"><i class="material-icons">monetization_on</i></a></li>
<li><a class="btn-floating blue" href="https://youtu.be/C_YBBupebvE" target="_blank" title="Video Tutorial"><i class="material-icons">video_library</i></a></li>
<li><a class="btn-floating green" href="http://www.labnol.org/internet/file-upload-google-forms/29170/" target="_blank" title="How to Create File Upload Forms"><i class="material-icons">help</i></a></li>
</ul>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"></script>
<script src="https://gumroad.com/js/gumroad.js"></script>
<script>
var file,
reader = new FileReader();
reader.onloadend = function(e) {
if (e.target.error != null) {
showError("File " + file.name + " could not be read.");
return;
} else {
google.script.run
.withSuccessHandler(showSuccess)
.uploadFileToGoogleDrive(e.target.result, file.name, $('input#name').val(), $('input#email').val());
}
};
function showSuccess(e) {
if (e === "OK") {
$('#forminner').hide();
$('#success').show();
} else {
showError(e);
}
}
function submitForm() {
var files = $('#files')[0].files;
if (files.length === 0) {
showError("Please select a file to upload");
return;
}
file = files[0];
if (file.size > 1024 * 1024 * 5) {
showError("The file size should be < 5 MB. Please <a href='http://www.labnol.org/internet/file-upload-google-forms/29170/' target='_blank'>upgrade to premium</a> for receiving larger files in Google Drive");
return;
}
showMessage("Uploading file..");
reader.readAsDataURL(file);
}
function showError(e) {
$('#progress').addClass('red-text').html(e);
}
function showMessage(e) {
$('#progress').removeClass('red-text').html(e);
}
</script>
背景说明和道歉
嗨,所有,
我意识到这个问题可能已经回答,但请耐心等待,因为我不是程序员,也没有自己写这个脚本,所以我不确定哪个以前的答案可能适用于我的问题。
这就是说,我很乐意删除我的问题,或者如果有人能够指出我的方向正确,请将它关闭为重复。
最后,我没有与这个脚本结婚,所以如果有人有一个更好的脚本来建议具有所有功能(多个文件上传,没有文件大小限制),我愿意提供建议。
我也愿意使用任何可以让我上传到我的Google云端硬盘的任何东西,只要它是免费的,因为我们是一个没有资金的志愿者组织,这只是一个功能,可以让我们的成员提交他们的文章为我们组织的通讯。
再次感谢(可能)重复问题!
您好里茨 我已经复制了附件代码在我的HTML表单不知何故,它不工作,你可以请审查 https://stackoverflow.com/questions/46256481/allow-multiple-files-upload-on-google-apps-script-no T-工作 – KiKu