I am new to JQuery and I want to use JQuery Ajax to upload some files to server, Only in PUT method. when I send some binary file(such as gif or jpeg) to my server, upload succeed, but the content of binary data was changed(it's always bigger than original file size). I try to change the content-type or the type of file result, but still not work. Anyone knows how to fix this?
PS: I cannot encode the binary file's content into other form, because I cannot touch the code of server.
var reader = new FileReader();
reader.onloadend = (function(Thefile) {
$.ajax({
url: url,
processData:false,
//contentType:"application/octet-stream; charset=UTF-8",
data: file.result,
type: 'PUT',
success : function(){console.log("OK!");},
error : function(){console.log("Not OK!");}
});
})(file);
reader.readAsBinaryString(file);
ajaxfunction processes data before sending the request.