an HTML form with its enctype attribute set to 'multipart/form-data'
request.files[]: fetches file and saves it to the desired location
secure_filename()

app.config[‘UPLOAD_FOLDER’]: Defines path for upload folder
app.config[‘MAX_CONTENT_PATH’]: Specifies maximum size of file yo be uploaded – in bytes

example:

mkdir uploadfd

vi templates/upload.html

<html>
   <body>

      <form action = "/uploadfd" method = "POST"
         enctype = "multipart/form-data">
         <input type = "file" name = "file" />
         <input type = "submit value='upload""/>
      </form>

   </body>
</html>
vi upload.py
from flask import Flask, render_template, request
from werkzeug import secure_filename
ap = Flask(__name__)

@ap.route('/upload')
def upload():
   return render_template('upload.html')

@ap.route('/uploadfd', methods = ['GET', 'POST'])
def upload_file():
   if request.method == 'POST':
      f = request.files['file']
      f.save('uploadfs/' + secure_filename(f.filename))
      return 'file uploaded successfully'

if __name__ == '__main__':
   ap.run(host='0.0.0.0')

==

http://code.runnable.com/UiPcaBXaxGNYAAAL/