将文件发送到Nodejs服务器

时间:2020-03-20 00:44:09

标签: jquery node.js

我一直在使用Jquery和Nodejs处理和接收表单数据。我想知道是否有一种将文件上传到Nodejs后端的方法,所以我开始进行研究,但是大多数关于堆栈溢出的解决方案已有5年以上的历史了。随着时间的流逝,我想知道这些天是否有更好的上传文件的方法。

对于我的常规ajax请求,我一直在做这样的事情:

 $.ajax({
            type:"POST",
            url:"/alterDetails",
            data:{
                 //data

            },
            success:function(data){
                $.toast({
                    title: 'Detail changed',
                    subtitle: '',
                    content:data.recordset[data.recordset.length-1].Description,  //Display the last item of audit description which would be the last audit made
                    type: 'success',
                    delay: 7000
                  });
            }

        })

是否可以使用相同的ajax请求设置,但可以将文件添加到POST请求中?

0 个答案:

没有答案