簡體   English   中英

如何使用Google App腳本將用戶選擇的文件上傳到Google雲端硬盤中的文件夾?

[英]How would I go about uploading a user-chosen file to a folder in my Google Drive using Google App Script?

基本上,我希望用戶能夠選擇其圖像之一,將其上傳,然后將其保存到我的Google雲端硬盤中的特定文件夾中。 到目前為止,這是我在HTML / Javascript方面所擁有的...

 <form> Photo: <input type="file" name="photo" id="p" accept="image/png, image/jpeg"><br> <input type="button" onClick="formSubmit()" value="Add"> </form> <script> function formSubmit() { var pic = document.getElementbyId("p").value; google.script.run.doPost(pic); } </script> 

...這就是我在Google應用腳本方面的功能...

 function doGet() { return HtmlService.createHtmlOutputFromFile('index'); } function doPost(pic) { var folder = DriveApp.getFolderById('1bMuxCecrBRo8fToRRvW6q7S9_9OUQHV1'); folder.createFile(pic); } 

我對Google App腳本和javascript很陌生,因此將不勝感激。 謝謝。

這是語法錯誤:應該是document.getElementById("p").value而不是document.getElementbyId("p").value (大寫“ B”)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM