后台用res.send(“DDFDFDF”)发送的字符串,前台在ajax({})中的success:function(data)就可以读出DDFDFDF,如果用var files = fs.readFileSync(file.path, ‘utf-8’);……res。send(files),前台ajax({})success的function (data)读时就读的是空串?
@1340641314
function doUpload() {
var formData = new FormData($( “#tijiao” )[0]);
$.ajax({
url: ‘http://localhost:1337/’ ,
type: ‘POST’,
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (data) {
alert(data);
document.getElementById(“myDiv”).innerHTML = data;
},
error: function (returndata) {
alert(returndata + ‘aa’);
}
});
}
我的前台代码,
后台是 res.send(fileb.toString(‘utf-8’, start=0, end=fileb.length));
还是传不上