如何使用AngularJS发布二进制文件(使用上传DEMO)无法发送带有角度后呼叫的文件我试图.mp4通过带有角度1的离子1 发布带有一些数据的文件。虽然通过POSTMAN发布它很好并且正常工作。我正在Success = false申请。在POSTMAN中,没有标题和数据如下, 表单数据中带有POST请求的服务URL http://services.example.com/upload.php正文j_id = 4124, type = text
q_id = 6, type = text
u_id = 159931, type = text
file = demo.mp4, type = file在我的应用程序:$rootScope.uploadQuestion = function () {
var form = new FormData();
form.append("j_id", "4124");
form.append("q_id", "6");
form.append("u_id", "159931");
form.append("file", $rootScope.videoAns.name); //this returns media object which contain all details of recorded video
return $http({
method: 'POST',
headers: { 'Content-Type': 'multipart/form-data' }, // also tried with application/x-www-form-urlencoded
url: 'http://services.example.com/upload.php',
// url: 'http://services.example.com/upload.php?j_id=4124&q_id=8&u_id=159931&file='+$rootScope.videoAns.fullPath,
// data: "j_id=" + encodeURIComponent(4124) + "&q_id=" + encodeURIComponent(8) + "&u_id=" + encodeURIComponent(159931) +"&file=" + encodeURIComponent($rootScope.videoAns),
data: form,
cache: false,
timeout: 300000
}).success(function (data, status, headers, config) {
if (status == '200') {
if (data.success == "true") {
alert('uploading...');
}
}
}).error(function (data, status, headers, config) {
});}
1 回答
- 1 回答
- 0 关注
- 586 浏览
添加回答
举报
0/150
提交
取消