Hi.

Did you add the code for file upload?

const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, "./files");
},
filename: (req, file, cb) => {
cb(null, `${file.fieldname}_${+new Date()}.jpg`);
}
});
const upload = multer({
storage
});
...
router.post("/uploadImage", upload.single('upload'), async (req, res, next) => {
res.json({
uploaded: true,
url: `${process.env.BASE_URL}/${req.file.filename}`
});
});

This is the part that gets file from the file upload request.

On front end, I have:

<CKEditor
editor={ClassicEditor}
data={content || ""}
onInit={editor => {
if (edit) {
setContent(doc.document);
}
}}
onChange={(event, editor) => {
const data = editor.getData();
setContent(data);
setDirty(true);
}}
config={{
ckfinder: {
uploadUrl:
`${APIURL}/pdf/uploadImage`
}
}}
/>

where:

config={{
ckfinder: {
uploadUrl:
`${APIURL}/pdf/uploadImage`
}
}}

actually does the upload.

Written by

Web developer. Subscribe to my email list now at http://jauyeung.net/subscribe/. Email me at hohanga@gmail.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store