I’m actually working with google apps script and I was trying to use a method for uploading files, so I executed this code that I found in a web site:
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;
}
first I had that message error TypeError: Cannot read property “parameter” from undefined. (line 15) than I changed this line with this:
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>
And than when I executed the code again I had this error: Cannot find method createFile($Proxy841);
I really do not know what is the problem !
Can anybody please help me !
Thanks in advance.
Your first version is correct, are you sure you used this version to run your test ? did you use a ‘dev’ version or an ‘exec’ version ? You should not make the changes you suggested in the second part of your question, this is not how it works.
see screen capture below :