help :O
class upload:
def GET(self):
return """This endpoint only accepts POSTS from file_upload.html"""
def POST(self):
x = web.input(fupFile={}, ref_id="")
if x:
# print x # ref_id
# web.debug(x['fupFile'].filename) # This is the filename
# web.debug(x['fupFile'].value) # This is the file contents
# web.debug(x['fupFile'].file.read()) # Or use a file(-like) object
ref_id = (x.ref_id if x.ref_id else "")
filename = "%s.tmp" % (ref_id)
fullpath = os.path.join("tmp", filename)
with open(fullpath, 'w') as f_out:
if not f_out:
raise Exception("Unable to open %s for writing." % (fullpath))
f_out.write(x["fupFile"].file.read()) # writes the uploaded file to the newly created file.
# all done, we loop back to the file_upload.html page, but this time include
raise web.seeother("static/pages/file_upload.html?ref_id=%s&filename=%s" % (ref_id, filename))
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webpy+un...@googlegroups.com.
To post to this group, send email to we...@googlegroups.com.
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.