β

Answer by zangw for I Want to Upload a File Using

User zangw - Stack Overflow 47 阅读

According to your codes posted in your question, it is hard to figure out the root cause of error . Here is one sample to upload file which I used before, please try it.

app.post('/upload/create', function(req, res){  
    //save the upload file to folder tmp/  
    var tmppath = req.files.file.path;  
    var targetpath = '/tmp/'+req.files.file.name;  
    fs.rename(tmppath, targetpath, function(err){  
        if (err) throw err;  
        fs.unlink(tmppath, function(){  
          if (err) throw err;  
          console.log('upload file successfully...');  
      });  
  });
作者:User zangw - Stack Overflow
most recent 30 from stackoverflow.com
原文地址:Answer by zangw for I Want to Upload a File Using , 感谢原作者分享。

发表评论