Encoding file names without ascii

For uploads using drop zone.js, file names containing non-ascii characters will not be encoded before being sent to the server. They are simply left as they are:

------WebKitFormBoundaryvXgdeNXSwHZBUrFJ
Content-Disposition: form-data; name="file[0]"; filename="täst.png"

As a result, server-side encoding is unknown.

Is there a way to get dropzone.js to give UrlEncode a file name similar to RFC 6266?

Content-Disposition: form-data; name="file[0]"; filename*=utf-8''t%c3%a4st.png

Or is there another solution?

+4
source share
2 answers

I ran into the same problem, and what I decided to do was pass an extra parameter.

$("#myDz").dropzone({
    init: function () {
        this.on("sending", function(file, xhr, formData) {
            var fn = encodeURI(file.name)
            formData.append("encFilename", fn);
        });
    }
});

encFilename , . file.name , , , .

+3

IamNaN . Java WS:

 filename = java.net.URLDecoder.decode(filename, "UTF-8");
0

Source: https://habr.com/ru/post/1606152/


All Articles