使用multer更新mongdb模式中的个人资料图片。但是保存时出错

时间:2018-12-19 16:53:45

标签: javascript node.js mongodb forms mongoose

我试图在与其他文档分开的mongodb模式中发布profile_pic。

const userSchema = mongoose.Schema({
firstname: {type: String},
lastname: {type: String},
username: {type: String},
email: {type: String},
password: {type: String},
profile_pic: {
    type: String
},
points: {
    total: {type: Number},
    test: {type: Number},
}
});

使用html POST方法

<form action="/image" method="POST" enctype="multipart/form-data">
    <div class="file-field input-field col s6">
        <div class="btn">
            <span>File</span>
            <input type="file" name="profile_pic">
        </div>
        <div class="file-path-wrapper ">
            <input class="file-path validate" type="text" placeholder="Upload your profile picture">
        </div>
    </div>
    <div class="col s6 input-field">
        <button class="btn waves-effect waves-light" type="submit" style="background:#5fcf80;">Submit
            <i class="material-icons right">send</i>
        </button>
    </div>
</form>

但是我只想将其保存到数据库中

0 个答案:

没有答案