0
我使用CKeditor爲我的網站。將圖像成功上傳到雲端之後,我無法獲取網址。它說「圖片源URL丟失」。我知道如果圖像上傳屬性模式的URL丟失,ckeditor無法顯示圖像。但我不知道如何獲得網址.... 這是我的代碼,但不工作。ckeditor,nodejs - 如何獲取圖像的網址?
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);
});
});
什麼是輸出,在格蘭當u打印結果的console.log finally塊(結果) – user1428716
它沒有打印任何東西......但是當我把'console.log代碼'放到最後一個bock的第一行時,它成功地打印結果。 – ShutUpILoveYou
顯示內部打印的輸出最後var htm; .. console.log – user1428716