2017-10-03 7 views
3

ノードjsを使用してquickbloxでコンテンツをアップロードしています。以下は私が使用しているコードです。node.jsを使用してquickbloxでコンテンツをアップロードできません

[0] [0] .files iは

VARで、inputFile = $( "入力[タイプ=ファイル]")のエラーを取得する画像のアップロード中に、 ^ $が

exports.upload = function(req, res){ 
    var CREDENTIALS ={ 
    appId: 0000, 
    authKey: 'xxxxx', 
    authSecret: 'yyyyyyyy' 
    }; 
QB.init(CREDENTIALS.appId, CREDENTIALS.authKey, CREDENTIALS.authSecret); 
    var user ={ 
    id: 1234, 
    name: 'abcd', 
    email: '[email protected]', 
    pass: 'qwertyuiop' 
    }; 

QB.createSession({email: user.email, password: user.pass 
    }, function(err,res){ 
    console.log(res) 
    if (res){ 
     var inputFile = $("input[type=file]")[ 
       0 
      ].files[ 
       0 
      ]; 
     var params ={name: inputFile.name, file: inputFile, type: inputFile.type, size: inputFile.size, 'public': false 
      }; 
     QB.content.createAndUpload(params, function(err, response){ 
     if (err){ 
      console.log(err); 
       } 
     else{ 
      console.log(response); 
      var uploadedFile = response; 
      var uploadedFileId = response.id; 
       } 
      }); 
     } 
    }); 
} 

答えて

1

使用document.querySelector( "入力[タイプ=ファイル]")が定義されていません。ファイル[0]ではなく$( "入力[タイプ=ファイル]")[0] .files [0]。または、JQueryを追加してください

関連する問題