title: Python 3.6: How to save file with unicode/utf-8 filename?
body: <p>So I'm having trouble to write a file upload in flask that writes unicode filenames.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>   for name, file in request.files.items():
  
          if secure_filename(file.filename) in alternate_file_index: 
  
              path_to_save = "/test-unicode/B-286_10 - \u8907\u88fd.xls"
  
              # file.save(path_to_save) didnt work
  
              with open(path_to_save, "wb") as save_file:
                  save_file.write(file.read())
          else:
              # English name files
              path_to_save = "path/to/save"
              file.save(path_to_save)
  </code></pre>
  
  <p>Error:</p>
  
  <p>if I use path_to_save.encode("utf-8"), I get:</p>
  
  <pre><code>    fdst.write(buf)
  AttributeError: 'bytes' object has no attribute 'write'
  </code></pre>
  
  <p>file.save(path_to_save) gives this error:</p>
  
  <pre><code> File "/flaskapp/env/lib/python3.6/site-packages/werkzeug/datastructures.py", line 2703, in save
      dst = open(dst, 'wb')
  UnicodeEncodeError: 'ascii' codec can't encode characters in position 54-55: ordinal not in range(128)
  </code></pre>
  
  <p>All the cases in english characters works great. </p>
  
  <p>Any advice would be appreciated. Ty.</p>
  
  <p>Answer:
  After posting this questions on stackoverflow, the bug has been magically solved.</p>
  
  <p>PS:
  path_to_save.encode("utf-8") works. Apparently, I missed that moment when the program runs. LOLZ...</p>