【发布时间】:2016-12-17 09:53:36
【问题描述】:
我有一种情况,我将文件从 Jquery 发送到我的快速服务器,我需要将该请求传输到另一台服务器而不在快速服务器中解析文件。这是我到目前为止使用的代码 sn-ps jQuery
$.ajax({
url: 'api/auth/handle',
type: 'POST',
data: data, // formData
cache: false,
dataType: 'json',
processData: false, // Don't process the files
contentType: false, // Set content type to false as jQuery will tell the server its a query string request
success: function (data, textStatus, jqXHR) {
console.log("success");
},
error: function (jqXHR, textStatus, errorThrown) {
// Handle errors here
console.log('ERRORS: ' +textStatus);
// STOP LOADING SPINNER
}
});
表达js代码
module.exports.handleFile = (req, res) => {
console.log(req);
let data = request.post("http://localhost:5002/files/pdf", function (err, resp, body) {
//console.log(err);
if (err) {
console.log('Error!');
} else {
console.log('URL: ' + body);
}
});
let form = data.form();
form.append('file', '<FILE_DATA>', req);
res.status(200).send({ "success": "success" });
};
问题是我没有在我的第二台服务器上获取表单数据。 任何建议都会有所帮助。谢谢
【问题讨论】:
标签: javascript jquery node.js express multipartform-data