使用Angular和Node上传文件
File upload using Angular and Node
我正在努力实现以下目标:
- 客户将简历作为表单的一部分上传
- AngularJS将所有表单数据(包括CV)发送到Node服务器
- 节点将CV存储在服务器上
我似乎就是无法让它发挥作用。我试着用骡子,但没有用。
到目前为止,我有以下几种:
HTML
<form name="register" enctype="multipart/form-data" method="post" ng-submit="registerSubmit(user)">
<input type="email" placeholder="Email" ng-model="user.email" />
<input type="file" id="cv" name="cv" ng-model="user.cv" />
<button type="submit"></button>
</form>
角度
app.controller("MainController", function($scope, $http){
$scope.registerSubmit = function(user){
$http.post("/api/register", user).success(function(data){
console.log(data);
});
});
});
节点(配置Express和其他模块)
app.use("/api", router);
router.post("/api/register", function(req, res){
//file not coming through and not sure what to do with it here anyway!
});
您必须将请求编码为"多部分/表单数据"。检查这个类似的问题:使用$http 上传文件
相关文章:
- 使用Angular和Node上传文件
- 将CSV文件从URL导入Node.js
- node.js的webtorrent通过magnet链接收集所有文件
- node.js将字符串转换为要上传到Web服务器的文件
- 如何使用Node.js在JavaScript模块文件之间使用事件处理程序
- 如何在node.js中只下载文件的前10 KB
- 如何从Node Webkit应用程序中退出外部CMD文件
- 如何从Node.js执行.exe文件
- 使用angularjs和node.js时的Web应用程序文件夹结构
- 处理字段中带有换行符的csv文件-node.js
- Node.js:在修改时确定文件大小
- 将对象添加到json文件-Node.js
- 并行读取多个文件,并相应地将数据写入新文件node.js
- 创建并发送Zip文件-NODE JS
- 从远程下载Mp3文件.Node js
- 如何将变量从express视图传递到router.js文件- Node JS
- 合并音频文件- node js
- 将解析逻辑拆分为单独的文件Node.js
- 如何正确使用客户端和服务器端的javascript文件-Node.js
- 将数组而不是字符串传递给函数以上传文件(node.js)的解决方案