Python Forum
Serving mixed filenames with send_from_directory() errors out.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Serving mixed filenames with send_from_directory() errors out.
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django serving wrong template at the wrong address with malformed urls.py (redactor a Drone4four 2 424 Aug-17-2020, 01:09 PM
Last Post: Drone4four
  [Flask] flask not submitting text entry when mixed with checkbox entries Prince_Bhatia 4 4,334 Oct-12-2018, 05:40 PM
Last Post: snippsat
  Cannot serve file with send_from_directory nikos 2 982 Sep-19-2018, 09:25 PM
Last Post: nikos

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020