title: Use flask to get an image uploaded on a html form
body: <p>I am new to flask and i am using google colab to do some basic flask stuff.</p>
  <p>I have a html-form:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;h1&gt;The input accept attribute&lt;/h1&gt;
  
  &lt;form action=&quot;#&quot; method=&quot;post&quot;&gt;
    &lt;label for=&quot;img&quot;&gt;Select image:&lt;/label&gt;
    &lt;input type=&quot;file&quot; id=&quot;img&quot; name=&quot;img&quot; enctype=&quot;multipart/form-data&quot; accept=&quot;image/*&quot;&gt;
    &lt;input type=&quot;submit&quot; value=&quot;submit&quot;&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>Then i have FLASK code as to get the uploaded image:</p>
  <pre><code>@app.route(&quot;/test&quot;, methods=['POST','GET'])
  def test_page():
    if request.method == &quot;POST&quot;:
      image = request.files.get('img', '')
      image = request.form[&quot;img&quot;]
  
      print(&quot;img &quot;,image)
      return &quot;&lt;h1&gt; yo! &lt;/h1&gt;&quot;
    else:
      return render_template('index.html') 
  </code></pre>
  <p>DEBUGGING RESULTS:</p>
  <pre><code>#debug
  print('request.method', request.method)
  print('request.args', request.args)
  print('request.form', request.form)
  print('request.files', request.files)
  
  request.method POST
  request.args ImmutableMultiDict([])
  request.form ImmutableMultiDict([('img', 'cat.jpg')])
  request.files ImmutableMultiDict([])
  </code></pre>
  <p>The problem is i want to doo some processing on the uploaded image but request.files return nothing and request.form just gives me the name. Please any help will be appreciated.</p>