title: Can't get uploaded file in Twisted
body: <p>I am trying to get a simple service running that will accept file uploads via an HTTP POST, however I'm having some trouble figuring out where the actual file data resides after the post request completes.</p>
  
  <p>The code I have thusfar is:</p>
  
  <pre><code>from twisted.web.server import Site
  from twisted.web.resource import Resource
  from twisted.internet import reactor
  
  #import cgi
  
  class FormPage(Resource):
      def render_GET(self, request):
          return """
  &lt;html&gt;
  &lt;body&gt;
  &lt;form method="POST"&gt;
      Text: &lt;input name="text1" type="text" /&gt;&lt;br /&gt;
      File: &lt;input name="file1" type="file" /&gt;&lt;br /&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  """
  
      def render_POST(self, request):
          response = '&lt;p&gt;File: %s&lt;/p&gt;' % request.args['file1'][0]
          response += '&lt;p&gt;Content: %s&lt;/p&gt;' % request.content.read()
          return '&lt;html&gt;&lt;body&gt;You submitted: %s&lt;/body&gt;&lt;/html&gt;' % (response)
  
  root = Resource()
  root.putChild("form", FormPage())
  factory = Site(root)
  reactor.listenTCP(8080, factory)
  reactor.run()
  </code></pre>
  
  <p>And the response I get is:</p>
  
  <blockquote>
    <p>You submitted:</p>
    
    <p>File: test.txt</p>
    
    <p>Content: text1=sdfsd&amp;file1=test.txt</p>
  </blockquote>
  
  <p>Most <a href="https://stackoverflow.com/questions/3271155/how-can-i-accomplish-file-uploads-in-twisted-web-that-dont-suck">everything else</a> I can find on the subject refers to using an <code>IRequest</code> object which <em>supposedly</em> has an <code>IRequest.files</code> property, but it is not listed in the <a href="http://twistedmatrix.com/documents/12.3.0/api/twisted.web.iweb.IRequest.html" rel="nofollow noreferrer">documentation</a>, and it throws an error when I run it.</p>
  
  <p>The end goal after receiving the file will be to move it to a particular folder, and then run some further code.</p>