title: Flask web application can't upload file
body: <p>I am using the following code to upload a file to a directory on the server. Each time I upload a file and press submit 'file' is not found in request.files. Any ideas?</p>
  
  <p>views.py:</p>
  
  <pre><code>@app.route("/upload_file")
  def upload_file(self):
      return self.render_template('upload_file.html')
  
  @app.route("/file_uploader", methods=['GET', 'POST'])
  def file_uploader(self):
      if request.method == 'POST':
          #application gets to this if block and returns 'No file part'
          if 'file' not in request.files:
              flash('No file part')
              return redirect(request.url)
          file = request.files['file']
  </code></pre>
  
  <p>upload_file.html:</p>
  
  <pre><code>&lt;h2&gt;Please select a dataset to upload.&lt;/h2&gt;
  &lt;form method=post enctype=multipart/form-data action={{ url_for('file_uploader')}}&gt;
      &lt;span class="btn btn-primary btn-file"&gt; Browse &lt;input type="file"&gt;&lt;/span&gt;
      &lt;input type=submit class="btn btn-success" value=Upload&gt;
  &lt;/form&gt;
  </code></pre>