使用post方法发送请求时找不到错误404

时间:2015-05-22 14:10:18

标签: javascript angularjs node.js http-status-code-404

我得错了:POST http://xyz:3000/upload 404(未找到)。 在客户端我发送请求(抱歉,我无法公开真实网址):

$scope.upload = function (files) {
    if (files && files.length) {
        for (var i = 0; i < files.length; i++) {
            var file = files[i];
            var reader = new FileReader();
            var text = '';
            reader.onload = function(e) {
                text = reader.result;
                $http.post('http://xyz:3000/upload', { 

                    file: { 
                        content: text, 
                        name: file.name, 
                        username: window.user.username
                    }
                })
                .success(function(file_name){
                    $scope.log = 'File ' + file_name + ' is uploaded successfully!' + '\n';
                    $scope.log += 'You can use ' + file_name + ' dataset now.';
                });
            }
            reader.readAsText(file, 'UTF-8');

并在服务器端:

'use strict';

    module.exports = function(app) {
        var upload = require('../../app/controllers/upload.server.controller');

        app.route('/upload')
            .post(upload.create);

有人可以帮忙吗?它在本地工作,但当我将这些代码推送到我的服务器时不会。

0 个答案:

没有答案