-1

I have an upload process to store data in server side in a directory common to all seesion:

def upload_file():
if request.method == 'POST':
    # check if the post request has the files part
    if 'files[]' not in request.files:
        flash('No file part')
        return redirect(request.url)
    files = request.files.getlist('files[]')
    machine = request.form.get('machine')
    for file in files:
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(UPLOAD_FOLDER, machine, filename))
    flash('File(s) successfully uploaded')
    return redirect(url_for('upload_form')

How can I change this code to save the file to session specific instance allowing multiple session to work on their own file ? How can I recover this file ?

Please note no database process allowed.

Sylvain Page
  • 581
  • 1
  • 7
  • 21

1 Answers1

0

If you don't want to use a database process and you are uploading the file on the server, you can use flask sessions by importing sessions from flask module and store the filename path uploaded by any user in their respective session and always open the file with the file path in the sessions and close after the use.

More details regarding sessions: https://pythonbasics.org/flask-sessions/

mtiTayyab
  • 11
  • 3