Search code examples
google-apps-scriptgoogle-docsgoogle-docs-api

Upload an image to s document


I am making a photo shooting contest, the competitor should register using a Google registration form, and upload his photo as well. I searched all over the internet to find a Google script that can be inserted into a form to upload a file using Google forms but could not find anything. Is it doable and how, and even if there can be other ideas to do such thing please let me know.


Solution

  • Try this

    function insertImage() {
      // Retrieve an image from the web.
      var resp = UrlFetchApp.fetch("http://www.google.com/intl/en_com/images/srpr/logo2w.png");
    
      // Create a document.
      var doc = DocumentApp.openById("");
    
      // Append the image to the first paragraph.
      doc.getChild(0).asParagraph().appendInlineImage(resp);
    }
    

    This link might help you as well :)

    http://code.google.com/googleapps/appsscript/class_documentapp_listitem.html#appendInlineImage

    Happy coding !