I have simple form to ajax-upload files to server.
Here is input event listener:
$(document).on('change', '.js-file', function(event){
sendFile(event);
});
And here is the function that actually uploads the file:
function sendFile (event) {
var files = event.target.files;
var action = '/ajax-upload-files/';
var data = new FormData();
$.each(files, function(key, value)
{
data.append(key, value);
});
$.ajax({
url: action,
type: 'POST',
data: data,
cache: false,
dataType: 'json',
processData: false,
contentType: false,
success: function(data){
},
complete: function(data) {
}
});
}
It wors fine with all kinds of files, except those with non-latin characters in the file name, e.g. Максим.jpg
The data is being sent to server, as I see in Chrome network. But when I try to dump $_FILES on server, it seems to be empty.
var_dump($_FILES) //array(0) {}
I don't really understand what's wrong - contentLength of the request header is much smaller then it should be - it looks like file was not appended to form for some reason.