Forgive the possible duplicity of this question, but after hours of searching to no avail, I've elected to ask the following of the community:
Is there any means by which, using the following form with HTML and Javascript (with a POST or GET request) that I might be able to have a user, from a normal HTML page, be able to submit and upload a file to Google Drive by means of having the "form action =" being directed at a Google Script?
I have been able to successfully write values to a Google Spreadsheet using only a form action directed to a Google Script which holds a single doPost(e) which then grabs the e.parameter.[input_field_name_here] and performs the calculations.
I have been toying with a combination of methods, but this is about as far as I've been able to get.
Current HTML:
<form method="post" action="my_google_script_published_as_web_app_url/exec" name="quoteForm" id="quoteForm" target="hidden_iframe">
<input type="file" name = "thefile">
</form>
Google Apps Script
function doPost(e)
{
var fileBlob = e.parameter.thefile;
Logger.log(e);
Logger.log(fileBlob);
var doc = DocsList.createFile(fileBlob.getBlob());
}
I have attempted the following variations with the code in order to try to perform an upload via this method:
- Added the
enctype="multipart/form-data"
to the form to see if that was an issue. - Attempted to use a "GET" request instead.
The closest I have been able to get in terms of an acutal useable result is an error return of "unable to convert Array to BlobSource" and, a further result of "unable to to call .getBlob() on type string" as well as "...on type Object".
Is there any hope to this at all? I've been trying to glean what I could from here, as well as the following two issues regarding what sounds like bugs related to a method like this here and here with the latter seeming the closest to what I'm facing.
Many thanks in advance for any assistance on this matter.