Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //blog image upload
- const blogImageUploadController = async (req, res, next) => {
- try {
- var TempFile = req.files.upload;
- var TempPathfile = TempFile.path;
- const targetPathUrl = path.join(__dirname,"../../../public/"+TempFile.name);
- if(path.extname(TempFile.originalFilename).toLowerCase() === ".png" || ".jpg"){
- fs.rename(TempPathfile, targetPathUrl, err =>{
- res.status(200).json({
- uploaded: true,
- url: `http://localhost:3030/${TempFile.name}`
- });
- if(err) return console.log(err);
- })
- }
- console.log(TempPathfile)
- }catch (err) {
- console.log(err)
- res.json ({
- message: err.message
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement