【发布时间】:2019-03-04 23:53:48
【问题描述】:
我在尝试让我的代码正常工作时遇到问题,但我没有从 multer 中得到任何错误。相信我,我到处检查,请帮忙。
//All the require functions that make the app work
const express = require('express')
const nodemon = require('nodemon')
const http = require('http')
const path = require('path')
const fs = require('fs')
const mongoose = require('mongoose')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const jwt = require('jsonwebtoken')
const config = require('./config/config.js')
const fileUpload = require('express-fileupload');
const https = require('https')
const mongoSanitize = require('express-mongo-sanitize');
var stripe = require("stripe")(config.stripeAPI);
var multer = require('multer')
var upload = multer({dest: "./uploads"}).single('photo');
app.post('/upload', (req, res, next) => {
var path = '';
upload(req, res, function (err) {
if (err) {
// An error occurred when uploading
console.log(err);
return res.status(422).send("an Error occured")
}
// No error occured.
path = req.files.path;
return res.send("Upload Completed for "+path);
});
});
这基本上就是我在示例中使用的内容
【问题讨论】:
标签: angular express npm multer