I am new to the Tornado platform and try to make a simple form for uploading images:
<form method="post" action="/uploads/{{uid}}/" enctype="multipart/form-data" > <input type="file" name="file1" /> <br /> Image info: <input type="text" name="alt" /> <br /> <input class="button" type="submit" value="Upload" class="button" /> </form>
I can successfully get the Submitted file using:
if 'file1' in self.request.files: if self.request.files['imgfile'][0]: file1 = self.request.files['imgfile'][0]
However, I cannot get the alt input. I tried alt = self.request.alt , but I get this error
AttributeError: 'HTTPServerRequest' object has no attribute 'alt'
and when I use alt = self.request.files['alt'] , I get:
KeyError: 'alt'
I'm out of ideas, so appreciate your help.
UPDATE:
I found this to work:
alt = self.get_argument('alt')
But still open to better solutions.
source share