title: How to solve "AttributeError: 'unicode' object has no attribute 'file'" once and for all in python webapp2 at file upload?
body: <p>I already saw similar questions here describing same problem, peoples gives there answers and someones even respond it helped, but nothing from it totally works for me.</p>
  
  <p>This is my code:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
    &lt;body&gt;
      &lt;form action = "/anomalydetector" enctype = "multipart-form-data" method = "post"&gt;
        File: &lt;input name = "attachment" type = "file" /&gt;&lt;br /&gt;
        Analyzer sensitivity in percents: &lt;input type = "text" name = "sensitivity" value = "10" /&gt;&lt;br /&gt;
        &lt;input type = "submit" value = "Analyze" /&gt;
      &lt;/form&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and the handler:</p>
  
  <pre class="lang-python prettyprint-override"><code>class AnomalyDetectorPage(webapp2.RequestHandler):
      def post(self):
          uploaded_file = self.request.POST.get("attachment");
          file_data = uploaded_file.file.read();
  </code></pre>
  
  <p>I always getting error of this kind:</p>
  
  <pre class="lang-pytb prettyprint-override"><code>  File "/base/data/home/apps/s~test-ml/1.398533980585659886/main.py", line 207, in post
      file_data = uploaded_file.file.read();
  AttributeError: 'unicode' object has no attribute 'file'
  </code></pre>
  
  <p>I understand that python thinks that files are strings, but what I can do with it???</p>
  
  <p>I tried <code>self.request.POST.get("attachment").file.read()</code>, <code>self.request.POST["attachment"].file.read()</code>, <code>self.request.get("attachment").file.read()</code> and <code>self.request.POST.multi["attachment"].file.read()</code> and maybe something else, but I always getting this error.</p>
  
  <p>What I can do to read content of this file?</p>