0
帆を使って画像をアップロードしようとしています。私は画像をアップロードすることができますが、私はモデルのパスをDBに渡してみたいので、投稿の一部であり、後で簡単に呼び出すことができます。帆画像アップロードのデータベースへのパス
"invalidAttributes": {
"image": [
"rule": "string",
"message": "Value should be a string (instead of null, which is an object)"
"rule": "required",
"message": "\"required\" validation rule failed for input: null\nSpecifically, it threw an error. Details:\n undefined"
"model": "Post",
は、ここで私が正しくあなたの質問を取得していない私のモデル
image: {
type: 'string',
required: true
},
そして、私のコントローラ
create: function (req, res, next) {
Post.create(req.params.all(), function postCreated(err, post) {
if (err) return next(err);
//image upload
req.file('image').upload({
dirname: '../../assets/images/'
}, function(error, uploadedFiles) {
// do something after file was uploaded...
});
// end upload
res.redirect('/post/show/' + post.id);
});
},
私は画像をアップロードし、画像の名前をデータベースに入れようとしています。 –
上記のコードを使用すると、データベースにイメージ名 "files [0] [0] .fd" –