Closed PeterMozesMerl closed 8 years ago
Unfortunately, I had no time to read the whole source code, so I’m wondering if there is a reason to not always encode the filename.
headers['X-File-Name'] = !this._opts.encodeCustomHeaders ? fileObj.name : encodeURIComponent( fileObj.name );
I think removing the condition and using the latter arm from the line above would solve the issue. Would this conflict with the line 1499 area? (Below)
if ( opts.encodeCustomHeaders && opts.customHeaders.hasOwnProperty( i ) ) {
xhr.setRequestHeader( i, encodeURIComponent( headers[ i ] ) + '' );
} else {
xhr.setRequestHeader( i, headers[ i ] + '' );
}
I just renamed files to both über.png and éber.png and it worked fine. Are you setting charset=UTF-8
on your page?
Can you try it on the demo and let me know what happens?
Fixed with 2.3 release. Closing out. Feel free to reopen if you have any issues.
Upload doesn’t work with either über.png or éber.png. These are valid characters in file names.
Uncaught SyntaxError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'éber.png' is not a valid HTTP header field value.
Chrome says it’s line 1499 on the demo site.
Note: I have an (~1-2 years) old version of Simple-Ajax-Uploader in production. Fortunately, it has no problem with the same file.