I am using the following html form to upload two files on gae
<form id="insert-budget-form" method="POST" action="" enctype="multipart/form-data" onsubmit="return validate()">
Budget Book Name:<br> <input type = "text" id = "bookName" name = "bookName" placeholder = "E.g. Budget Book 2016"/>
<br><br>
File:<br> <input type = "file" id = "bookFile" name = "bookFile"/>
<br><br>
Highlight:<br> <input type="file" id = "highlightFile" name = "highlightFile"/>
<br><br>
<input type="date" id="bookDate" name="bookDate"/>
<input type="submit" id="insert-budget-sub" value="Insert"/>
</form>
I am generating upload url using ajax when the user selects the first file and using jQuery I am assigning the url as an action to form
Now, at my server side , I am getting the first file, how to obtain the second file. Here is the server side code:
class BudgetBookUploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
bookName = self.request.POST.get('bookName')
bookDatetime = self.request.POST.get('bookDate')
dateParts = bookDatetime.split("-")
date = datetime.date(int(dateParts[0]), int(dateParts[1]), int(dateParts[2]))
if bookName != "" and date:
q = BudgetBook.query(BudgetBook.bookName == bookName)
if q.get():
self.redirect("/manage_budgetbook?success=dup")
else:
bookUpload = self.get_uploads()[0]
highlightUpload = self.get_uploads()[1]
budgetBook = BudgetBook(
bookBlobKey = bookUpload.key(),
highlightBlobKey = None,
bookName = bookName,
bookDate = date)
budgetBook.put()
self.redirect("/manage_budgetbook?success=true")
Is syntactically getuploads()[1] correct to use for getting the second file and storing it?