Ueditor uses node backend, and returns req.ueditor as undefined

problem description

Today, ueditor is used as a rich text editor. In the background, node-express, refers to the case of https://github.com/netpi/ueditor. When returned, req.ueditor prints the result as undefined.
clipboard.png

ueditor1.4.3.3let ueditor = require("ueditor")1.2.3ueditorindex.jsbusboy.on()
clipboard.png

related codes

/ / Please paste the code text below (do not replace the code with pictures)
my code:

let ueditor = require("ueditor")
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// /upload  https://github.com/netpi/ueditor/blob/master/example/public/ueditor/ueditor.config.js
//  serverUrl: URL + "php/controller.php"
//  serverUrl: URL + "ue"
app.use("/static/ueditor/ue", ueditor(path.join(__dirname, "../public/upload"), function(req, res, next) {
  // upload 
  console.log("ueditor",req.ueditor)
  if(req.query.action === "uploadimage"){
    // 
    var foo = req.ueditor;
    console.log(foo.filename); // exp.png
    console.log(foo.encoding); // 7bit
    console.log(foo.mimetype); // image/png

    //    path.join(__dirname, "../public/upload") 
    var img_url ="/img/";
    res.ue_up(img_url); // ueditor
  }else if (req.query.action === "listimage"){//  
    var dir_url =  "/img/"; // 
    res.ue_list(dir_url) //  dir_url 
  }else {// 
    res.setHeader("Content-Type", "application/json");
    //  ueditor.config.json 
    // let configPath = path.join(__dirname, "../static/ueditor/") + "ueditor.config.json";
    // console.log("configPath",configPath)
    res.redirect("/ueditor/ueditor.config.json");
  }})
);



I use demo on github , change your code to try, and prompt the backend configuration item is not loaded properly, and the upload plug-in cannot be used properly! , and then I change the configuration to the default configuration on github , which loads the upload button normally, and req.ueditor also has a value. Just still can not go to the upload breakpoint, and then I looked at the next github on the example is to write three conditions, I also try to judge the conditions, on it, and then I looked at the next action the value is uploadfile , the original I used an attachment upload, even if the picture is uploaded, but also directly determine the uploadfile type. After elimination, the rest may be the problem of your configuration.

the modified code has been changed for a total of three lines and can be used normally. You can try to replace it and study the configuration in the example in detail.
there are other situations communicating

   

Menu