0
我正嘗試上傳一張帶有快遞和多功能的圖片。下面是我用它來上傳圖片的形式:已上傳的圖片不適用於多人
<form action="/uploadProfilePicture" method="POST" id="form-upload-profile-picture">
<div class="row center">
<div class="row">
<input type="file" name="uploadProfilePicture" id="add-friend-search-input">
</div>
<div class="row">
<button class="button-green-large" class="u-full-width" id="add-friend-search-submit">Upload</button>
</div>
</form>
這裏是我的後端:
var mkdirp = require("mkdirp"),
multer = require("multer");
// MULTER CONFIGURATION
var storage = multer.diskStorage({
destination: function (req, file, cb) {
//var code = JSON.parse(req.body.model).empCode;
var dest = "/public/images";
mkdirp(dest, function (err) {
console.log(dest);
if (err) cb(err, dest);
else cb(null, dest);
});
},
filename: function (req, file, cb) {
cb(null, Date.now()+'-'+file.originalname);
}
});
// POST ROUTE: Upload profile picture
app.post("/uploadProfilePicture", upload.any(), function(req, res) {
console.log(req.body);
res.send(req.files);
});
但是,每當我上傳的圖片,它不會出現在/公/圖像。我的代碼有什麼問題?非常感謝!