【发布时间】:2016-09-20 02:48:04
【问题描述】:
我正在使用最新版本的KeystoneJS 并且有一个表单可以向数据库中添加记录。
我无法正常上传图片。
我的模型包含:
heroImage: { type: Types.CloudinaryImage, autoCleanup : true },
我的表格包括:
<input type="file" accept="image/*" id="heroImage" name="heroImage_upload" className='field-upload'>
我保存表单的中间件只包括:
view.on('post', {action: 'save'}, function(next)
{
var newProperty = new Property.model(req.body);
console.log(newProperty);
newProperty.save(function(err, body)
{});
});
它适用于除文件上传之外的所有领域。
我已经尝试添加:
newProperty.heroImage = req.files['heroImage'];
将heroImage 保留为空。
我也尝试创建cloudinaryImage,但这会导致错误:
var img = new CloudinaryImage(req.files['heroImage']);
当我使用KeystoneJS 管理仪表板上传图像时,一切正常。有人可以解释一下我应该如何在自己的表单中使用 cloudinaryImage 字段类型吗?
谢谢
【问题讨论】:
标签: express mongoose cloudinary keystonejs