标签:处理 var sub function user log efs pat mit
前台代码
submit() { var file = this.$refs.fileUpload.files[0]; var formData = new FormData(); formData.append("file", file); formData.append("username", this.username); formData.append("password", this.password); axios.post("http://127.0.0.1:3000", formData).then(res => { console.log(res); }); }
后台代码
app.use(function (req, res) { var form = new formidable.IncomingForm(); form.uploadDir = path.join(__dirname, ‘uploads‘) form.parse(req, function (err, fields, files) { fs.rename(files.file.path, path.join(__dirname, ‘uploads‘, files.file.name), function (err) { if (!err) { return res.end(‘ok‘) } res.end(‘err‘) }) }); })
注意
标签:处理 var sub function user log efs pat mit
原文地址:https://www.cnblogs.com/wuqiuxue/p/9210572.html