我实际上正在使用谷歌应用程序脚本并且我试图使用一种上传文件的方法,所以我执行了我在网站上找到的这段代码:
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;
}
首先我收到消息错误 TypeError: Cannot read property "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>
而当我再次执行代码时,我遇到了这个错误:找不到方法 createFile($Proxy841);
真不知道是什么问题!
任何人都可以帮助我!提前致谢。