According to RFC, in multipart/form-data content-disposition header filename field receives as parameter HTTP quoted string - string between quites where character '\' can escape any other ascii character.
The problem is, web browsers don't do it.
IE6 sends:
Content-Disposition: form-data; name="file"; filename="z:\tmp\test.txt"
Instead of expected
Content-Disposition: form-data; name="file"; filename="z:\\tmp\\test.txt"
Which should be parsed as z:tmptest.txt
according to rules instead of z:\tmp\test.txt
.
Firefox, Konqueror and Chrome don't escape " characters for example:
Content-Disposition: form-data; name="file"; filename=""test".txt"
Instead of expected
Content-Disposition: form-data; name="file"; filename="\"test\".txt"
So... how would you suggest to deal with this issue?
Does Anybody have an idea?
Though an old thread, adding the below java solution for whoever might be interested.
// import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.*;
try {
ContentDisposition contentDisposition = new ContentDisposition("attachment; filename=\"myfile.log\"; filename*=UTF-8''myfile.log");
System.out.println(contentDisposition.getParameter("filename"));
} catch (ParseException e) {
e.printStackTrace();
}