【问题标题】:send params to node server using cordova使用cordova将参数发送到节点服务器
【发布时间】:2014-07-09 20:24:50
【问题描述】:

我正在尝试在同一个请求中上传文件并发送参数,这可以通过文件传输实现,但我在服务器端遇到问题,req.body 始终为空,我正在使用强大的模块

这是客户端

        upload = function (imageURI) {
        var ft = new FileTransfer(),
            options = new FileUploadOptions();

        options.fileKey = "file";
        options.fileName = 'filename.jpg'; // We will use the name auto-generated by Node at the server side.
        options.mimeType = "image/jpeg";
        options.chunkedMode = false;


        var params = {};
        params.value1 = "test";
        params.value2 = "param";

        options.params = params;


        alert(imageURI);
        ft.upload(imageURI, serverURL + "/upload",
            function (e) {
                getFeed();
            },
            function (e) {
                alert("Upload failed");
            }, options);
    },

这是服务器端

var form = new formidable.IncomingForm();

 form.parse(req, function(error, fields, files) {
      console.log(req.body.value1);


console.log("Traitement terminé");

【问题讨论】:

    标签: node.js cordova


    【解决方案1】:

    我发现了我必须更换的问题

    console.log(req.body.value1);

    通过

    console.log(fields.value1);

    【讨论】:

      猜你喜欢
      • 2019-02-13
      • 2021-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多