Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gwt 获取错误:找不到方法createFile($Proxy841)_Gwt_Google Apps Script_Google Apps - Fatal编程技术网

Gwt 获取错误:找不到方法createFile($Proxy841)

Gwt 获取错误:找不到方法createFile($Proxy841),gwt,google-apps-script,google-apps,Gwt,Google Apps Script,Google Apps,实际上,我正在使用google apps脚本,并尝试使用一种上传文件的方法,因此我执行了在网站上找到的以下代码: function doGet(e) { var app = UiApp.createApplication().setTitle("Upload CSV to Sheet"); var form = app.createFormPanel().setId('frm').setEncoding('multipart/form-data'); var formContent

实际上,我正在使用google apps脚本,并尝试使用一种上传文件的方法,因此我执行了在网站上找到的以下代码:

  function doGet(e) {

 var app = UiApp.createApplication().setTitle("Upload CSV to Sheet");
 var form = app.createFormPanel().setId('frm').setEncoding('multipart/form-data');
 var formContent = app.createVerticalPanel();
 form.add(formContent);  
 formContent.add(app.createFileUpload().setName('thefile'));
 formContent.add(app.createSubmitButton('Submit'));
 app.add(form);
 return app;
 }

function doPost(e) {      // data returned is a blob for FileUpload widget 
var fileBlob = e.parameter.thefile; 
var doc = DocsList.createFile(fileBlob);  
var app = UiApp.getActiveApplication();           
//Display a confirmation message                           
var label = app.createLabel('file uploaded successfully');
app.add(label);  
 return app;  
  }
首先,我收到一条消息error TypeError:cannotreadproperty“parameter”from undefined。(第15行)之后,我将这一行更改为:

  var app = UiApp.getActiveApplication();    
   var fileBlob = app.getElementById('thefile');// in the doPost function      

   formContent.add(app.createFileUpload().setId('thefile'));</b>// I remplaced the setName with setId in the doSet function;</br>       
var-app=UiApp.getActiveApplication();
var fileBlob=app.getElementById('thefile');//在doPost函数中
formContent.add(app.createFileUpload().setId('thefile');//我在doSet函数中重新放置了带有setId的setName

当我再次执行代码时,出现了以下错误:找不到方法createFile($Proxy841)

我真的不知道是什么问题

谁能帮帮我吗!
提前谢谢

您的第一个版本是正确的,您确定使用此版本运行测试吗?您使用的是“dev”版本还是“exec”版本?你不应该做出你在问题第二部分中建议的改变,这不是它的工作原理

请参见下面的屏幕截图:


这就是我所做的我创建了一个新项目(脚本为web app)我保存了该项目,然后我运行doGet方法:它工作得很好,但是当我运行doPost方法时,我再次收到以下消息错误:TypeError:无法从undefined读取属性“parameter”。(第14行)!再次感谢你的回答!doPost不能单独调用,当按下“提交按钮”时会自动调用,这就是它的工作原理;-)事实上,如果您试图从脚本中调用doPost,您就不可能让它执行某些操作,因为“e”确实没有定义!e是doGet函数返回的“元素”。我建议您阅读文档和教程,看看这是如何工作的(无意冒犯:-)