Python 3 Flask Upload Multiple Files or Images Using HTML5 Form in Browser Full Project For Beginners



from flask import Flask, render_template, request
#from werkzeug import secure_filename
from werkzeug.utils import secure_filename
app = Flask(__name__)

def upload_file():
   return render_template('upload.html')

@app.route('/uploader', methods = ['GET', 'POST'])
def upload_file1():
   if request.method == 'POST':
      files = request.files.getlist("file")
      for file in files:

      return 'file uploaded successfully'

if __name__ == '__main__': = True)



Now make the templates folder and inside it make a upload.html file and copy paste the following code






      <form action = "http://localhost:5000/uploader" method = "POST" 
         enctype = "multipart/form-data">
         <input type = "file" name = "file" multiple/>
         <input type = "submit"/>



Now run the flask app by running the below command









Leave a Reply