当我尝试将文件上传到特定文件夹时,但我找不到可以从云端硬盘中选择指定文件夹的对象,
我在这里试过......
function doGet(e){
var app=UiApp.createApplication();
var panel=app.createHorizontalPanel();
var month1=app.createListBox().addItem("January").addItem("Febuary").addItem("March").setId("month12").setName("month12");
var upload=app.createFileUpload().setName("file");
var uploadbutton=app.createSubmitButton("UPLOAD");
panel.add(month1).add(upload).add(uploadbutton);
var form=app.createFormPanel();
form.add(panel);
app.add(form);
return app;
}
function doPost(e){
var app=UiApp.createApplication();
var month=e.parameter.month12;
var file=e.parameter.file; //user upload fileName
var files = DriveApp.getFolders();
while (files.hasNext()) {
var file = files.next();
var fileName=file.getName();
if(month==fileName){
var doc = DocsList.createFile(file); //that directly uploaded into the Drive List
Logger.log("inside");
}
}
return app;
}
DocsList直接将文件上传到云端硬盘中,如果我使用DriveApp.CreateFolder,则会在驱动器中创建一个文件夹。
答案 0 :(得分:0)
尝试使用(文件夹).createfile(“file”)而不是DocList函数。即。
var folder = DocsList.getFolder("MyFolder");
var fileBlob = Utilities.newBlob(e.parameter.file); // process blob ready to save
var doc = folder.createFile(fileBlob); // createfile in specified folder