gpt4 book ai didi

javascript - ckeditor,nodejs - 如何获取图像网址?

转载 作者:行者123 更新时间:2023-12-03 03:23:12 25 4
gpt4 key购买 nike

我的网站使用 CKeditor。成功将图像上传到 cloudinary 后,我无法获取 .它说“图像源 URL 丢失”。我知道如果图像上传属性模式上的 URL 丢失,ckeditor 就无法向我显示图像。但我不知道如何获取网址......这是我的代码,但不起作用。

router.post('/uploadImage',multipartMiddleware,(req,res,next)=>{
console.log(req.files);

let imageFile = req.files.upload.path;

cloudinary.uploader.upload(imageFile,
{
tags: 'photobook',
folder: req.body.category + '/',
public_id: req.files.upload.originalFilename

})
.then(function (result) {
console.log('Picture uploaded to Cloudinary');
// Check the image Json file
console.log(result);
// Save photo with image metadata
})
.then(function (result) {
console.log('Successfully saved');
// Remove image from local folder
var filePath = req.files.upload.path;
fs.unlinkSync(filePath);
//////-----------it works successfully here ------------////////
})
.finally(function (result) {
console.log('this log is well shown up');
var html;
html = "";
html += "<script type='text/javascript'>";
html += " var funcNum = " + req.query.CKEditorFuncNum + ";";
html += " var url = " + result.url;
html += " var message = \"upload successfully\";";
html += " window.parent.CKEDITOR.tools.callFunction(funcNum, url);";
html += "</script>";
console.log("it doesn't show up"); //really doesn't show up
// Show the result with image file
res.send(html);
});

});

最佳答案

问题是您没有将 url 包含在脚本标记内:

    html += " var url = " + result.url;

这应该有效:

    html += " var url = '" + result.url + "'";

关于javascript - ckeditor,nodejs - 如何获取图像网址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46473018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com