Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用方法Post AngularJs时出错_Angularjs_Postman - Fatal编程技术网

使用方法Post AngularJs时出错

使用方法Post AngularJs时出错,angularjs,postman,Angularjs,Postman,有人可以修复它,当我使用邮递员我的restfull是好的,但不是从我的客户端 var req = { method: 'POST', url: 'http://localhost:8098/getfiles', headers: { 'Content-Type': 'multipart/form-data', }, data: { 'selectedFiles': 'D:\\quadtech

有人可以修复它,当我使用邮递员我的restfull是好的,但不是从我的客户端

   var req = {
        method: 'POST',
        url: 'http://localhost:8098/getfiles',
        headers: {
          'Content-Type': 'multipart/form-data',
        },
        data: { 'selectedFiles': 'D:\\quadtech\\Intellegent\\AppSpringBoot\\input\\bismillah.txt' }
    }   
    return $http(req).then(function(response){console.log(response); return response;}, function(){});
我的控制台中的错误是

POST http://localhost:8098/getfiles 500 ()
这是邮递员的要求
使用formData而不是data发送:

    var req = {
            method: 'POST',
            url: 'http://localhost:8098/getfiles',
            headers: {
              'Content-Type': 'multipart/form-data',
            },
            formData: {
              'selectedFiles': fs.createReadStream('D:\\quadtech\\Intellegent\\AppSpringBoot\\input\\bismillah.txt') }
            }   
        return $http(req).then(function(response){console.log(response); return response;}, function(){});

请参阅文档:

您的服务器需要表单数据。您正在发送JSON。如果您在浏览器开发工具的“网络”面板中查看发送的请求,这一点就显而易见了。使用正确的内容类型,以正确的格式发送数据。'content-type':'multipart/form data'使用此选项时出现错误500