我正在尝试将文件上传到我的Google云端硬盘。
在服务器端,我有这个:
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('Index.html')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
function processForm( form )
{
}
这是带有客户端javascript的HTML
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script src="https://code.jquery.com/jquery.min.js"></script>
</head>
<body>
<h1>Upload test</h1>
<form >
File1 <input type="file" name="file1" id="file1" > <br>
<input type="button" value="Submit" onclick="pre_submit_check( this.parentNode )" >
<div id='message'>
</div>
</form>
</body>
<script>
function pre_submit_check( thisForm )
{
google.script.run
.processForm( thisForm );
}</script>
根据the entry for google.script.run,我应该能够将表单从客户端传递到服务器端,但这样做会产生此错误&#34;拒绝显示&#39; https://script.google.com/a/macros/ .. .. func = processForm&#39;在一个框架中因为它设置了X-Frame-Options&#39;到#sameorigin&#39;。
当我使用setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)时,行为是相同的;我所读到的应该绕过这个限制。
这是来自客户端的console.log
userCodeAppPanel:1拒绝显示 &#39; https://script.google.com/a/macros/sjsu.edu/s/AKfycbwgUQIH3Oh78HrrhjultwKLuqSf7s1fkX7QCF4W6EA/postform?nocache_id=1&token=AJuLMu3zKyGB1DMff2VLg1MxcBMWKZFbLQ%3A1503682662444&fsid=1da35034-7a52-4a9d-a5ec-a125f4f9b771&func=processForm&#39; 在一个框架中因为它设置了X-Frame-Options&#39;和#or; sameorigin&#39;。 1484611146-mae_html_user_bin_i18n_mae_html_user.js:77 POST https://script.google.com/a/macros/sjsu.edu/s/AKfycbwgUQIH3Oh78HrrhjultwKLuqSf7s1fkX7QCF4W6EA/postform?nocache_id=1&token=AJuLMu3zKyGB1DMff2VLg1MxcBMWKZFbLQ%3A1503682662444&fsid=1da35034-7a52-4a9d-a5ec-a125f4f9b771&func=processForm net :: ERR_BLOCKED_BY_RESPONSE Sf.i @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:77 Ve.h @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:56 t.ga @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:52 gg.J @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:86 md @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:30 id @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:31(匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:28 postMessage (异步)Ti.f @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:153 ve @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:70 Ni @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:150(匿名) @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:19 v.wa @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:145 Od @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:60 T @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:58 yg @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:85 Wh.j @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:133 Od @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:60 T @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:58 Fh @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:119 v.Pa @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:118 v.ya @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:118 XMLHttpRequest.send(async)v.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:116 Wh.ua @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:132 wg.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:85 v.Za @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:143 v.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:142 $ h.D @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:137 Mi.f @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:149 je.c @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:66 Ui @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:153 Ti.j @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:152 postMessage (async)Qe @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:85 t.la @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:50 (匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:6 (匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:40 pre_submit_check @ userCodeAppPanel:7 onclick @ userCodeAppPanel:1 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:116 GET https://script.google.com/a/macros/sjsu.edu/s/AKfycbwgUQIH3Oh78HrrhjultwKLuqSf7s1fkX7QCF4W6EA/postresponse?nocache_id=3&fsid=1da35034-7a52-4a9d-a5ec-a125f4f9b771&token=AJuLMu3zKyGB1DMff2VLg1MxcBMWKZFbLQ%3A1503682662444 500()v.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:116 Wh.ua @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:132 wg.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:85 v.Za @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:143 v.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:142 $ h.D @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:137 Mi.f @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:149 je.c @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:66 Ui @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:153 Ti.j @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:152 postMessage (async)Qe @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:85 t.fa @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:53 Tf @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:83(匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:6 md @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:30 id @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:31(匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:28 1484611146-mae_html_user_bin_i18n_mae_html_user.js:49未听见 NetworkError:HTTP 500 g导致连接失败 1484611146-mae_html_user_bin_i18n_mae_html_user.js:49 Oe @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:55(匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:6 gg.J @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:86 md @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:30 id @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:31(匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:28 postMessage (异步)Ti.l @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:154 ve @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:70 Oi @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:150(匿名) @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:19 v.wa @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:146 Od @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:60 T @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:58 yg @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:85 Wh.j @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:133 Od @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:60 T @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:58 Dh @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:117 Fh @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:119 v.Pa @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:118 v.ya @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:118 XMLHttpRequest.send(async)v.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:116 Wh.ua @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:132 wg.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:85 v.Za @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:143 v.send @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:142 $ h.D @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:137 Mi.f @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:149 je.c @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:66 Ui @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:153 Ti.j @ 3189932465-mae_html_driver_bin_i18n_mae_html_driver.js:152 postMessage (async)Qe @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:85 t.fa @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:53 Tf @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:83(匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:6 md @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:30 id @ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:31(匿名)@ 1484611146-mae_html_user_bin_i18n_mae_html_user.js:28
非常感谢任何帮助。