How to change the upload folder during the runtime? I'd like to be able to change the location where file will be uploaded to, but I don't know how.
I tried something like this, but I get KeyError:
@app.route('/upload', methods=['POST'])
def upload():
    file = request.files['file']
    path = 'uploads/text'
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        UPLOAD_FOLDER = path
        file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
        return redirect(url_for('uploaded_file',
                                filename=filename))
                You can try this
file.save(os.path.join(/path/to/save/, filename))
In yours
UPLOAD_FOLDER = path
file.save(os.path.join(UPLOAD_FOLDER, filename))
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With