如何解决无法使用 cloudinary 上传图片
我无法将图片上传到 cloudinary,我认为这与我放置 cloudinary 上传器功能有关,据说我已尝试重组,但仍然无法正常工作。
抱歉我错过了错误! "typeError 无法读取 'path' 的属性。
userRouter.post('/property',upload.single('propertyImage'),passport.authenticate('jwt',{session : false}),(req,res)=>{
console.log(req.files);
const property = new Property({
street: req.body.street,town: req.body.town,area: req.body.area,PostCode: req.body.PostCode,NoBeds: req.body.NoBeds,NoBath: req.body.NoBath,NoLivingRooms: req.body.NoLivingRooms,askingPrice: req.body.askingPrice,propertyImage: image_url
});
const {propertyImage} = files;
cloudinary.uploader.upload(
propertyImage.path,{ folder: "/houseImage/" },async (error,results) => {
const image_url = results.url;
property.save(err=> {
if(err)
res.status(500).json({message : {msgBody: "Error has occured",msgError : true}});
else{
req.user.properties.push(property);
req.user.save(err=> {
if(err)
res.status(500).json({message : {msgBody: "Error has occured",msgError : true}});
else
res.status(200).json({message: {msgBody: "Successfully created property",msgError : false}});
})
}
})
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。