问题描述
这是AJAX代码,用于触发表单提交中的帖子。
$(".commonForm").submit(function (e) {
e.preventDefault();
alert("coming");
$.ajax({
type: "POST",url: $(this).attr('action'),success: function(r){
console.log("result",r)
},error: function (e) {
console.log("some error",e);
}
});
// }
});
这是我想尝试使用直接在路由中发送的multer的路由代码:
router.route('/api/upload/:cid').post(upload.array("FileUploadForClient",12),(req,res,next) => {
console.log("File is uploaded");
});
我什至收到控制台消息,但实际上未上传文件。 由于我必须在客户端执行一些验证,因此我尝试这种方式。有什么办法吗?
P.S:
我不想使用以下方式的代码:
upload(req,function(err) { if(err) { return res.end("Error uploading file."); }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)