[Twisted-Python] Twisted file upload
Syver Enstad
syver at inout.no
Tue Oct 14 06:31:27 MDT 2003
If there is a better way to get the filename of a posted file than the
code below, please tell me:
""" this is a workaround because
twisted web doesn't make the filename accessible
on a form with enctype='multipart/form-data'
"""
savedPosition = request.content.tell()
try:
request.content.seek(0)
request.content.readline()
match = re.search(r'filename="([^"]+)"',
request.content.readline())
if match:
return match.group(1)
else:
return None
finally:
request.content.seek(savedPosition)
More information about the Twisted-Python
mailing list