【发布时间】:2016-05-18 01:21:37
【问题描述】:
这个问题包括一个框架的细节,但我只是有一个关于如何将照片文件上传到 api 的一般问题。我提交的图像的实际部分是什么?照片的内容是什么?
单击按钮后,我能够成功上传图像(使用 angular-file-uploader。但是,我不知道我应该将该对象的哪个部分发送到我的 api。
下面的代码会报类型错误:无法将循环结构转换为 JSON。
所以我也可以尝试从队列中抓取文件,但是当它进入 cloudinary 时,我收到一个错误:TypeError: file.match is not a function。
html
<div>
<input type="file" nv-file-select uploader="user.uploader" />
<button ng-click="user.upload()">Upload</button>
</div>
控制器
vm.upload = function() {
console.log(vm.uploader);
var photo = {file: vm.uploader.queue[0]}
UserDisplay.uploadPhoto($stateParams.user_id, vm.uploader.queue[0])
}
API
cloudinary.uploader.upload(req.body.file, function(result) {
console.log("made it here");
console.log(result)
});
【问题讨论】:
标签: angularjs api upload mean cloudinary