Python Forum

Full Version: Serving mixed filenames with send_from_directory() errors out.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In an html form i have a user selecting a filename, which then i tried to send to his browser. Here is the code:

    filename = request.form.get('filename') 
    filepath = '/home/nikos/wsgi/static/files/' 

    return send_from_directory(filepath, filename) 
If the filename selected is in english characters it gets send the user, but, if it contained a mix of english + greek chars it gives a bad request i tried to encode `filename.encode("utf-8") but then NO files are being served.