node.js - Sending parameters with file - Delivery.js and socket.io -


i'm trying upload file using nodejs,socket.io , delivery.js. file upload working fine me, need send parameters file.but don't see how can that! here's code far.

client.html

var socket = io.connect();    var delivery = new delivery(socket);    function sendfile(){      delivery.on('delivery.connect',function(delivery){          var file = document.getelementbyid("file").files[0];         var extraparams = {foo: 'bar'};         delivery.send(file, extraparams); //trying send params file         return false;     });      delivery.on('send.success',function(fileuid){       alert("file sent.");     });    } 

and server.js

io.sockets.on('connection', function(socket){   var delivery = dl.listen(socket);   delivery.on('receive.success',function(file){   // delivery.on('receive.success',function(file,params){<--tried      var params = file.params;     console.log(params);     fs.writefile(file.name,file.buffer, function(err){       if(err){         console.log('file not saved.');       }else{         console.log('file saved.');       };     });   }); }); 

but console.log(params) prints undefined. grateful if point me right direction.

update: solved issue cloning github deliver.js,the npmjs code seems outdated.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -