GoogleAppEngineLauncher version 1.7.0
I'm trying to develop a service in which users can upload json files.
# -*- coding: utf-8 -*-
> import os, cgi
> import cgitb; cgitb.enable()
> import logging
> from handler import Handler
class Upload(Handler):
> def get(self):
> self.render('upload.html')
> def post(self):
> form = cgi.FieldStorage()
> fileitem = form['filejson']
> logging.error(fileitem)
> if fileitem.filename:
> logging.error('uploaded')
> fn = os.path.basename(fileitem.filename)
> open('files/' + fn, 'wb').write(fileitem.file.read())
> message = 'The file "' + fn + '" was uploaded successfully'
> else:
> logging.error('upload failed')
> message = 'No file was uploaded'
<form enctype="multipart/form-data" action="_upload" method="post">
> <p>File: <input type="file" name="filejson"></p>
> <p><input type="submit" value="upload" class="btn btn-large
> btn-primary"></p>
> </form>
Handler class works fine. But this code raises an error,
File "/Users/ishidasouichi/Dropbox/AppEngine/worddata/upload.py", line 16, in
post
fileitem = form['filejson']
File "/usr/local/Cellar/python/2.7.3/lib/python2.7/cgi.py", line 541, in
__getitem__
raise KeyError, key
KeyError: 'filejson'
I have searched the web but could not find relevant resolutions to this
problem.
Can anyone tell me where the problem is?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-appengine/-/9j-BE6jaWR0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.