title: Twisted upload muliple files key error
body: <p>I'm attempting to write a Twisted Webserver in Python 3.6 that can upload multiple files but being fairly new to both Python and things Web I have ran into an issue I don't understand and I also do not find any good examples relating to multiple file upload.</p>
  
  <p>With the following code I get</p>
  
  <pre><code>from twisted.web import server, resource
  from twisted.internet import reactor, endpoints
  import cgi
  
  
  class Counter(resource.Resource):
      isLeaf = True
      numberRequests = 0
  
      def render_GET(self, request):
          print("GET " + str(self.numberRequests))
          self.numberRequests += 1
          # request.setHeader(b"content-type", b"text/plain")
          # content = u"I am request #{}\n".format(self.numberRequests)
          content = """&lt;html&gt;
          &lt;body&gt;
          &lt;form enctype="multipart/form-data" method="POST"&gt;
              Text: &lt;input name="text1" type="text" /&gt;&lt;br /&gt;
              File: &lt;input name="file1" type="file" multiple /&gt;&lt;br /&gt;
              &lt;input type="submit" /&gt;
          &lt;/form&gt;
          &lt;/body&gt;
          &lt;/html&gt;"""
          print(request.uri)
  
  
          return content.encode("ascii")
  
      def render_POST(selfself, request):
          postheaders = request.getAllHeaders()
          try:
              postfile = cgi.FieldStorage(
                  fp=request.content,
                  headers=postheaders,
                  environ={'REQUEST_METHOD': 'POST',
                          # 'CONTENT_TYPE': postheaders['content-type'], Gives builtins.KeyError: 'content-type'
                           }
              )
          except Exception as e:
              print('something went wrong: ' + str(e))
  
          filename = postfile["file"].filename #file1 tag also does not work
          print(filename)
  
          file = request.args["file"][0] #file1 tag also does not work
  
  
  
  endpoints.serverFromString(reactor, "tcp:1234").listen(server.Site(Counter()))
  
  reactor.run()
  </code></pre>
  
  <p>Error log</p>
  
  <pre><code>C:\Users\theuser\AppData\Local\conda\conda\envs\py36\python.exe C:/Users/theuser/PycharmProjects/myproject/twweb.py
  GET 0
  b'/'
  # My comment POST starts here
  Unhandled Error
  Traceback (most recent call last):
    File "C:\Users\theuser\AppData\Local\conda\conda\envs\py36\lib\site-packages\twisted\web\http.py", line 1614, in dataReceived
      finishCallback(data[contentLength:])
    File "C:\Users\theuser\AppData\Local\conda\conda\envs\py36\lib\site-packages\twisted\web\http.py", line 2029, in _finishRequestBody
      self.allContentReceived()
    File "C:\Users\theuser\AppData\Local\conda\conda\envs\py36\lib\site-packages\twisted\web\http.py", line 2104, in allContentReceived
      req.requestReceived(command, path, version)
    File "C:\Users\theuser\AppData\Local\conda\conda\envs\py36\lib\site-packages\twisted\web\http.py", line 866, in requestReceived
      self.process()
  --- &lt;exception caught here&gt; ---
    File "C:\Users\theuser\AppData\Local\conda\conda\envs\py36\lib\site-packages\twisted\web\server.py", line 195, in process
      self.render(resrc)
    File "C:\Users\theuser\AppData\Local\conda\conda\envs\py36\lib\site-packages\twisted\web\server.py", line 255, in render
      body = resrc.render(self)
    File "C:\Users\theuser\AppData\Local\conda\conda\envs\py36\lib\site-packages\twisted\web\resource.py", line 250, in render
      return m(request)
    File "C:/Users/theuser/PycharmProjects/myproject/twweb.py", line 42, in render_POST
      filename = postfile["file"].filename #file1 tag also does not work
    File "C:\Users\theuser\AppData\Local\conda\conda\envs\py36\lib\cgi.py", line 604, in __getitem__
      raise KeyError(key)
  builtins.KeyError: 'file'
  </code></pre>
  
  <p>I don't understand how to get hold of the file or files so I can save them uploaded after the form Submit in render_POST. This post <a href="https://stackoverflow.com/questions/11553751/twisted-web-keep-request-data-after-responding-to-client">SO</a> appears to not have this problem. The final app should be able to do this asynchronous for multiple users but before that I would be happy to get just a simple app working.</p>
  
  <p>Using conda on Windows 10 with Python 3.6</p>