new了formidable的一个实例。

    formidable模块可以直接捕获当前数据流的状态并返回文件路径。

  主要使用了file事件和end事件。

var form = new formidable.IncomingForm();
form.uploadDir="/localnonobank/test/images/";
form.on('file', function(name,file){
filepath=file.path;
filename=file.name;
});
form.parse(request, function(err,fields,files){
if(err){
throw err;
};
});

form.on('end', function() {
fs.rename(filepath,form.uploadDir+filename);
response.end(JSON.stringify({name:filename,src:form.uploadDir+filename}));
});

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
猜你喜欢
  • 2021-11-03
  • 2022-01-15
  • 2021-06-01
  • 2022-01-08
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
相关资源
相似解决方案