2

I would like to use Google Sites to create a web site, where users can upload files. These uploaded files are stored at Google Drive, and data about the file is stored in a Google spreadsheet.

Are there any open-source applications or tutorials or libraries which can help make this possible? If not, can anybody explain how to do this?

  • Try Google Apps Script for that. See also Chrome Web Store for GAS apps. – Jacob Jan Tuinstra May 9 '13 at 13:20
1

Maybe JotForm is a solution -> http://www.jotform.com/blog/62-Send-Your-Form-Uploads-to-Google-Drive

  • 1
    Hi, perhaps you can put a snippet of the answer here so that this answer can stay valid when the link becomes dead? Thanks! – Hydra May 15 '13 at 0:43
1

Try this code in a web app script. This code generate a Submit button and then ask for a file that the user can upload directly to a preconfigured folder of Google Drive.

var app = UiApp.createApplication();
function doGet() {

  var formContent = app.createVerticalPanel();
  formContent.add(app.createFileUpload().setName("DSRfile"));
  formContent.add(app.createSubmitButton("Start Upload"));
  var form = app.createFormPanel();
  form.add(formContent);
  app.add(form);

  return app;
}

function doPost(e){
  var DSRload = e.parameter.DSRfile;
  var folders = DriveApp.getFolders();
  while(folders.hasNext()){
    var folder = folders.next();
    if(folder.getName() === 'Expedientes'){
      var Doc = DriveApp.createFile(DSRload).getId();
      var file = DriveApp.getFileById(Doc);
      folder.addFile(file);
      break;
    }
  }

  // Display a confirmation Message
  var label = app.createLabel("File Upload Successful");
  var clickHandler = app.createServerHandler('close');
  app.add(label).add(app.createButton('close this window', clickHandler));
  Logger.log('Va a cerrar 1');
 // return app ?;OJO con esta linea activa, muestra error
}

function close(){
  //OJO No entra a esta función
  Logger.log('Va a cerrar 2');
  //return UiApp.getActiveApplication().close();
  return app.close();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.